Need help... I got this macro from ExcelTip.com (thanks to Ron de Bruin) basically to find the last filled row.

I would like to use this as a worksheet function in cell (A2). As such, I entered =LastRow(), but the result is #VALUE. I did not pass any parameter into the function as I assume it will take the current Activesheet.

Can someone help to show some lights with regards to this problem? Thanks in advance.


Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function