Worksheet boundaries
To obtain the last populated row and last populated column use the following ...
Function EndPoints() As Integer()
Dim endpoint(2) As Integer
' Get last populated row and column
endpoint(0) = Cells.SpecialCells(xlCellTypeLastCell).Row
endpoint(1) = Cells.SpecialCells(xlCellTypeLastCell).Column
EndPoints = endpoint
End Function
savename.sql
Here's an example showing how to reference this macro ...
Sub Boundaries()
Dim lastrowcol() As Integer
lastrowcol = EndPoints()
MsgBox ("Last Row: " & lastrowcol(0) & "; Last Column: " & lastrowcol(1))
End Sub
savename.txt
Please note that if you have removed the contents of lines these will still be in the mix when it comes to using the macro ... to reset the worksheet boundaries to reflect the current non-blank cells, go to the first cell in the worksheet and save the file.