A VBA snippet on how to get the last row and column in the worksheet.

Xybernetics Excel - Get Last Row And Column

Here is the code so that you don’t have to type.

[sourcecode language=”csharp”]
Private Sub GetLastRowNCol()
‘ The number 1 in this statement means Column 1
lngLastRow = Cells(Rows.Count, 1).End(xlUp).Row
‘ The number 4 in this statement means Row 4
lngLastCol = Cells(4, Columns.Count).End(xlToLeft).Column

MsgBox lngLastRow & " | " & lngLastCol</code></pre>
End Sub