Function FindLastRowInRange(rng As Range) As Long
'Description: finds the last row in a range
'Inputs: Range
'Outputs: Row number (long); zero if error occurs
' check range
If rng Is Nothing Then Exit Function
On Error Resume Next
FindLastRowInRange = Application.WorksheetFunction.Max( _
rng.Find(What:="*", _
After:=rng.Cells(1), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).row, _
rng.Find(What:="*", _
After:=rng.Cells(1), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).row)
On Error GoTo 0
End Function