papa jonah

P

Papa Jonah

I am trying to find a simple formula that I can use to return the row number
for the last entry on a sheet. In other words, if I have 987 rows of data, I
would like this formula (to be included in a cell or VBA) to return "987" as
the value.

TIA
 
G

Gord Dibben

Papa

If the data is numeric........

=MATCH(9.99999999999999E+307,A:A)

If the data is text...........

=LOOKUP(REPT("z",255),A:A)

VBA code to rturn the row number......

Sub FindLastRow()
Dim LastRow As Long
If WorksheetFunction.CountA(Cells) > 0 Then
LastRow = Cells.Find(What:="*", after:=[A1], _
SearchOrder:=xlByRows, _
searchdirection:=xlPrevious).Row
MsgBox LastRow
End If
End Sub

Gord Dibben Excel MVP
 

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