How to Find Row Number of Active Cell For VBA

Written by stephanie ellen
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Find Row Number of Active Cell For VBA
(Jupiterimages/Comstock/Getty Images)

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

Show MoreHide

Instructions

  1. 1

    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).

  2. 2

    Click "Insert" and then click "Module" to open a blank module window.

  3. 3

    Cut and paste the following code into your worksheet:

    Sub RowNum()

    MsgBox "The active cell row is " & ActiveCell.Row

    End Sub

  4. 4

    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."

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.