View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Eric[_27_] Eric[_27_] is offline
external usenet poster
 
Posts: 43
Default counting # rows in a worksheet

Public Function FindLastRow() As Long
'Find the last used Row on a Worksheet:
If WorksheetFunction.CountA(Cells) 0 Then
'Search for any entry, by searching backwards by Rows.
FindLastRow = Cells.Find( _
What:="*", _
After:=[A1], _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious) _
.Row
End If
End Function

"HeatherO" wrote in message
...
I currently have a program that opens up mutiple workbooks anyways I am
never
sure of how many rows of data are in the worksheet that I need to use for
a
vlookup in which I need to access the whole range. One day the workbook
could have data stored from A2:G55 and the next A2:G100. I was just
wondering if there is a way to count the number of rows in a worksheet
that
hold data so I could pick the right range to lookup. Something like a
rowcount() maybe?
Any help is appreciated.
Thanks a bunch.