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.
Things You'll 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 & Warnings
- You can also access the VBE by clicking "Developer" and then "Visual Basic."
- Photo Credit Jupiterimages/Comstock/Getty Images
How to Get the Address of a Selection in VBA
When programming in VBA, you may find it necessary to retrieve the address of the cell selection for the code. For instance,...
How to Use VBA to Go to the Last Row in an Excel Sheet
Learning how to use Visual Basic for Applications (VBA) in Excel can save you time when searching for data in a worksheet....
How to Use Variables to Select a Cell in VBA
Visual Basic for Applications (VBA) is a programming language used exclusively for Microsoft Office applications. VBA allows you to customize Excel by...
How to Select a Cell Using VBA
Microsoft Excel's in-built Visual Basic for Applications (VBA) language allows you to expand Excel by creating your own code to automate processes,...
How to Copy & Paste to Available Rows in Macro
Microsoft Excel is especially fond of contiguous ranges. When a range is broken up by empty cells, Excel adds a layer of...
How to Use ActiveCell in Excel Using a VBA
If you work with Microsoft Office Excel often it's good to know how to use the "ActiveCell" property to add, get, and...
How to Change an Active Cell to Another Cell in Excel 2003
Setting an active cell in Microsoft Excel 2003 involves the use of Visual Basic for Application programming. VBA lets you automate functions...