Function GetLastCellInColumn(rg As Range) As Range
Dim lMaxRows As Long
lMaxRows = ThisWorkbook.Worksheets(1).Rows.Count
If IsEmpty(rg.Parent.Cells(lMaxRows, rg.Column)) Then
Set GetLastCellInColumn = _
rg.Parent.Cells(lMaxRows, rg.Column).End(xlUp)
Else
Set GetLastCellInColumn = rg.Parent.Cells(lMaxRows, rg.Column)
End If
End Function
|