How to identify the row from which a UDF is being executed?

TCH

New Member
Joined
May 23, 2012
Messages
9
Hello,

I need to identify the row number from which my UDF is being executed .

I want reference cells("the row" , 1), but don't know how to reference the row number.

Obviously, ActiveCell.Row is not appropriate but was used as an example.

Thanks for your help.

Ted H.


Function OnTime_30_OnTime()

Application.Volatile True

Analyst = Cells(ActiveCell.Row, 1)

OnTime_30_OnTime = Worksheets(Analyst).Range("AS1")

End Function
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
It would be Application.Caller.Row or Application.ThisCell.Row but neither is very good design - you'll probably have to make your function volatile if you adopt this form of indirect referencing.
 
Upvote 0
Have you considered using the native and volatile function INDIRECT? So, for example...

=INDIRECT("'"&A2&"'!AS1")
 
Upvote 0
Rory,

Thanks for your reply.

My code now reads: Analyst = Cells(Application.Caller.Row, 1) and works perfectly.

Thanks again.

Ted H
 
Upvote 0
Domenic,

Thanks also for your reply.

I will your method as it is more straight-forward and won't involve using VBA code as I had originally envisioned.

Thank you.

Ted H
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top