Address of cell invoking current UDF call?

E

Eddie

I would like to write a user defined function that, as part of its
execution, needs to know the cell address from which it is currently called.
I.e. if
cell A1
= UDF(parm1, parm2)
then,
what type of statement can I use in the UDF to return the executing cell
address "A1"?

Assuming, of course, that such a thing is possible. Thanks in advance.
Larry.
 
J

Jim Cone

Try out this udf...
'--
Function Sludge()
Sludge = Application.Caller.Address
End Function
'--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




"Eddie"
wrote in message
I would like to write a user defined function that, as part of its
execution, needs to know the cell address from which it is currently called.
I.e. if
cell A1
= UDF(parm1, parm2)
then,
what type of statement can I use in the UDF to return the executing cell
address "A1"?

Assuming, of course, that such a thing is possible. Thanks in advance.
Larry.
 
M

Mark Ivey

Here is one option...

Sub GetCurrentAddress()
Dim myCell As String
myCell = ActiveCell.Address
MsgBox myCell
End Sub


Mark Ivey
 
E

Eddie

Thanks, Mark. This works for the active cell, but a cell calling a user
defined function may not necessarily be the active cell -- which Jim's
solution gets at. But I still appreciate the help.

Gotta love these help groups. Seldom fail to find people willing to help
out.
 

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