There are a number of ways to count the rows that are "used' in a spreadsheet.
1) assumption there are no empty rows, you could look for the current region, this will give you a range as result. from there you can get the Row count... example:
DimMyRange as Excel.Range
Dim iRow as double Dim iRows as double
set MyRange=Activesheet.Cells(5,1).CurrentRegion
'iRows then will give you the number of rows in this Range....
iRows=MyRange.Rows
If after this you want to select this, just do:
Rows("5:" & iRows).select (or .Copy) or whatever you need.
2) on the assumption that there are empty rows in the range, just goto the last row in the sheet (ie: row= 65536 in excel97)
Activesheet.cells(65536,1).select
'and work your way up to the first row with anything in the first cell of that row...
activecell.end(xlup).row 'this will give you the row number of the LAST row with data...
so use this as follows:
iRows=activesheet.cells(65536,1).end(xlup).row
then set MyRange=range("5:" & iRows)
MyRange.copy (or MyRange.select)