Can I create a function in Excel?

G

Guest

I'm trying to build a function that takes few cells (including ranges), so that I can perform a calculation using those figures.

I'd like to use this function several times performing the same kind of calculation but using different cells and ranges. Ideally I can create a function similar to the ones already built in Excel (like PV, sum, etc...). How can I do that? Thanks a lot.
 
S

SidBord

There are two ways to write your own functions for use in
Excel.
You can use the "Define Name" facility that is normally
used to define a name for a cell or a range. It will also
accept a single line that calculates something using Excel
formula functions. So you can write the single line
formula, give it a name, then invoke it like a function.
The more flexible way is to write a Visual Basic macro,
which can be invoked on a worksheet IF it doesn't in any
way try to change anything on the worksheet. Calculating a
value is a good application for a macro function, since it
returns a value. To write the macro, you can go into
Tools->Macro->Record a Macro then start writng the function
as a formula or series of formulas. The macro facility will
generate a rudimentary macro for you, but you'll probably
want to clean it up or add/remove things. You'll have to
do some studying to write a macro, but the knowledge will
be invaluable.
-----Original Message-----
I'm trying to build a function that takes few cells
(including ranges), so that I can perform a calculation
using those figures.
I'd like to use this function several times performing the
same kind of calculation but using different cells and
ranges. Ideally I can create a function similar to the
ones already built in Excel (like PV, sum, etc...). How
can I do that? Thanks a lot.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top