ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   current row of user-defined function? (https://www.excelbanter.com/excel-programming/304598-current-row-user-defined-function.html)

usenethelp

current row of user-defined function?
 
Is it possible to get the row that a user-defined function is on?
ActiveCell.Row seems work, until you drag down to fill the function at
which time each funcion will return only the first cell (the
activecell). I think I need this in order to reference other cells in
the same row that the function is in.

Norman Jones

current row of user-defined function?
 
Hi Usenethelp,

Try:

Application.Caller.Row


---
Regards,
Norman


"usenethelp" wrote in message
om...
Is it possible to get the row that a user-defined function is on?
ActiveCell.Row seems work, until you drag down to fill the function at
which time each funcion will return only the first cell (the
activecell). I think I need this in order to reference other cells in
the same row that the function is in.




Bernie Deitrick

current row of user-defined function?
 
Use Net Help,

In your function, use:

Dim myRow As Long
Dim myVal As Variant

myRow = Application.Caller.Row
'To get data from column A
myVal = Application.Caller.Parent.Cells(myRow, 1).Value

HTH,
Bernie
MS Excel MVP

"usenethelp" wrote in message
om...
Is it possible to get the row that a user-defined function is on?
ActiveCell.Row seems work, until you drag down to fill the function at
which time each funcion will return only the first cell (the
activecell). I think I need this in order to reference other cells in
the same row that the function is in.




Tom Ogilvy

current row of user-defined function?
 
set rng = Application.Caller

will give a range reference to the cell containing the UDF

rng.row

would give you the row.

--
Regards,
Tom Ogilvy


"usenethelp" wrote in message
om...
Is it possible to get the row that a user-defined function is on?
ActiveCell.Row seems work, until you drag down to fill the function at
which time each funcion will return only the first cell (the
activecell). I think I need this in order to reference other cells in
the same row that the function is in.




Charles Williams

current row of user-defined function?
 
Dont forget that if your UDF references other cells like this

I think I need this in order to reference other cells in
the same row that the function is in.


that you will need to make it volatile ...

Application.volatile true

Charles
______________________
Decision Models
The Excel Calculation Site.
www.DecisionModels.com





usenethelp

current row of user-defined function?
 
Thanks guys!!


All times are GMT +1. The time now is 05:38 PM.

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