logo
Microsoft Excel - Interview Questions and Answers
How do you find the last row and column in VBA?
To find the last row, use the below lines code in the VBA module :
Sub FindingLastRow()

Dim lastRow As Long

  lastRow = ActiveSheet.Cells.SpecialCells(xlLastCell).Row

MsgBox (lastRow)

End Sub?


To find the last column, use the below lines code in the VBA module :

Sub FindingLastColumn()

Dim lastRow As Long

  lastColumn = ActiveSheet.Cells.SpecialCells(xlLastCell).Column

MsgBox (lastColumn)

End Sub