Place both the Sub and the Funciton in standard code module1.
Run Sub lstRw to see how it works. Make sure Sheet1 has data in it.
You can use it for any sheet and you can use Worksheet("shName") or
Worksheet(Index) or Sheets("shName") formats as arguments to return a valid
worksheet object. k will equal the row number.
Sub lstRw()
k = lastRow(Sheets(1))
MsgBox k
End Sub
Function lastRow(sh As Worksheet) 'Finds last cell with
On Error Resume Next 'data in the last used row.
lastRow = sh.Cells.Find(What:="*", After:=sh.Range("A1"), _
LookAt:=xlPart, LookIn:=xlFormulas, SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, MatchCase:=False).Row