Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting current row number in VBA

Status
Not open for further replies.

beakerboy

Technical User
May 31, 2001
27
US
I'd like to be able to determine the row number of the cell currently calling a specific funcion. Currently I call a public function as

=Find_Last_Entry(Glucose_Consumed,ROW())


I'm hoping there's a way for the VB to determine the row on it's own. I can't use Activecell.Row because the cell with this formula isn't always active.

Any Ideas?

Thanks
Kevin Nowaczyk
 
The only way is to provide the function with the row number using the ROW() function.

A function can be called from another function or macro so you cannot assume it will be called from a cell.

VBA questions are better posed in the VBA forum.
 
Since excel XP it is possible to use ThisCell property of Application object, returning the cell using UDF (as range object, Application.ThisCell.Row will return row number).

combo
 
Hi,

If you have data in every cell in the subject column, then the last row can be obtained using the COUNTA function.

For instance in column A...
[tt]
=COUNTA(A:A)
[/tt]
if you have empty rows above, subtract the number of empty rows.

Skip,

[glasses] [red]Be advised:[/red] Researchers have found another Descartes trueism, "Cogito ergo spud."
"I think; therefore, I YAM!
[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top