Visual Basic for Applications (VBA) is a subset of the programming language Visual Basic. VBA is used exclusively in Microsoft Office applications like Word, PowerPoint and Excel. If you are using VBA in Excel, you may want to write a macro, or executable code, that references the row number that the active cell is on--the active cell is the cell where the cursor is currently placed. A short piece of code will tell you the active cell's row number.
- Skill level:
- Moderately Challenging
Other People Are Reading
Things you need
- Excel 2010 or Excel 2007
Press "Alt" and "F11" together from inside the worksheet where you want to find the active cell's row number. This action opens the Visual Basic Editor (VBE).
Click "Insert" and then click "Module" to open a blank module window.
Cut and paste the following code into your worksheet:
MsgBox "The active cell row is " & ActiveCell.Row
Press "F5" to run the routine. The macro will return the active cell's row in a message box.
Tips and warnings
- You can also access the VBE by clicking "Developer" and then "Visual Basic."
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for