Line numbers are easy to handle -- the function FindLastRowWithData
Function LastRowWithData(ws As Worksheet, Optional MaxNumCellsUsed As Long = 1) As Long
Dim i As Long
For i = ws.UsedRange.Rows.Count To 1 Step -1
If Application.WorksheetFunction.CountA(ws.Rows(i)) > MaxNumCellsUsed Then
LastRowWithData = i
Exit Function
End If
Next i
End Function
'backs up' the used range until it finds a row with more than MaxNumCellsUsed (default = 1) of cells with something in them and assumes that that is the row where data ends
The For loops than can stop checking at that row since that's the end of 'meaningful' data