Sometimes you may want to write a macro that identifies the active row in your spreadsheet. This tutorial shows you how to get the current row in a spreadsheet using Excel VBA.
How to get the current row in a worksheet using Excel VBA
We will use the following data set in our illustration.

We use the following steps:
- Open the worksheet that contains the data set.
- In the active worksheet press Alt + F11 to open the Visual Basic Editor.
- Click Insert >> Module to create a new module.

- Type the following sub-procedure in the module.
1 2 3 |
Public Sub ActiveRow() MsgBox "The current row is row " & ActiveCell.Row End Sub |
- Save the procedure and save the workbook as an Excel Macro-Enabled workbook.
- Place the cursor anywhere in the procedure and press F5 to run the code.

A message box pops up in the active worksheet showing that row 6 is the current row. Note that row 6 is the current row because the cell selector is in cell A6.
Conclusion
This tutorial has demonstrated how to get the current row in a worksheet using Excel VBA.