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