UDF help

S

Salman

I need to use the address of a cell where I enter a UDF in
the UDF itself. How can I do that?

So the UDF code would say something like:

take column number of cell where function is entered
return the number of columns between function and column D

Thanks.
 
C

Chip Pearson

Salman,

Application.Caller will return a Range reference to the cell
which called the function.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
D

David McRitchie

Hi Salman,

A user defined function does not know the address where you
enter the function, you would have to include that as a parameter.

You can use a function in another macro that has absolution no
connection with any cell address.
i.e. convert_to_cubic_yards(500)

Can you use a worksheet function

H44: =COLUMN(H44) - COLUMN(D1)
 
T

Tom Ogilvy

in a UDF

Dim rng as Range
set rng = Applition.Caller

will set rng to the cell containing the UDF
 
D

David McRitchie

application.caller it is, now I've got to do 5 good replies to
make up for my mistake.

David
 
Top