Returning the Last Used Cell in a Column or Row with Worksheet
Function GetLastUsedRow(rg As Range) As Long
Dim lMaxRows As Long
lMaxRows = ThisWorkbook.Worksheets(1).Rows.Count
If IsEmpty(rg.Parent.Cells(lMaxRows, rg.Column)) Then
GetLastUsedRow = _
rg.Parent.Cells(lMaxRows, rg.Column).End(xlUp).Row
Else
GetLastUsedRow = rg.Parent.Cells(lMaxRows, rg.Column).Row
End If
End Function
Related examples in the same category