Problem with UDF

  • Thread starter Thread starter Liosan
  • Start date Start date
L

Liosan

Hello people,

If I have a user-defined function that I use to, say, calculate
cumulative total (I know I don't need VBA for this, it's just a
example). Is there any way I can retrieve the address of the cell wher
the UDF was called? or determine whether it was called by the use
inside the worksheet or by a diferent function?

If the answer to the first question is no, I will have to pass the cel
address explicitly as a parameter of the UDF. Whats the best way o
doing this? The obvious (for me) solution - passing the column and ro
numbers as integers - seems cumbersome. Is it possible to use the A
notation here?

Thanks for any help,

Liosa
 
Liosan

The Application.Caller method gives you the address of the cell from which
VBA was called. See the Help for some caveats though...

To get the address of a cell you can use the CELL worksheet function, e.g.
=CELL("address",E5) in E5 will give $E$5
 
How about:

If TypeOf Application.Caller Is Range Then
'called from cell
Else
'not called from cell
End If
 

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

Back
Top