ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Address of cell invoking current UDF call? (https://www.excelbanter.com/excel-programming/409793-address-cell-invoking-current-udf-call.html)

Eddie[_9_]

Address of cell invoking current UDF call?
 
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.



Jim Cone[_2_]

Address of cell invoking current UDF call?
 
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.



Mark Ivey[_2_]

Address of cell invoking current UDF call?
 
Here is one option...

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


Mark Ivey

"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.



Eddie[_9_]

Address of cell invoking current UDF call?
 
Exactly what I need. And simple to boot. Thanks!!

"Jim Cone" wrote in message
...
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"?



Eddie[_9_]

Address of cell invoking current UDF call?
 
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.

"Mark Ivey" wrote in message
...
Here is one option...

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


Mark Ivey

"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.





All times are GMT +1. The time now is 10:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com