Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Obtain Row and Column Information

  Asked By: Eva    Date: Nov 02    Category: MS Office    Views: 660
  

I am very new to VBA, so please excuse a simple-minded question.

I want to determine the row number of a selected cell. For example is
there something like the following?

myRow = SelectedRow()

Where SelectedRow() is some VBA command which will determine the row
number and place that number into the variable myRow.

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Yvonne Watkins     Answered On: Nov 02


Try:

myRow = Selection.Row

Some related items:

Selection.Row = row  of upper left cell  of selected  area
Selection.Column = column  of upper left cell of selected area
Selection.Count = Total cells in selected area
UBound(Selection.Formula,1) = # of rows in selected area
UBound(Selection.Formula,2) = # of columns in selected area

 
Answer #2    Answered By: Yvette Griffin     Answered On: Nov 02

does this get you on your way ?

SUB cellad

MsgBox (" THE ACTIVE cell  ADDRESS IS ") & ActiveCell.Address

End sub

 
Answer #3    Answered By: Brent Brown     Answered On: Nov 02

Use

ActiveCell.Row ()

ActiveCell is your current cell, and row  () is a method to return the row.

If you have an area selected, ActiveCell will be the one that is highlighted
differently.

If instead you use

Selection.Row ()

Then it returns the top row if you have a multi-row area selected.
Confirmed by help: "Returns the number  of the first row of the first area in
the range."

 
Didn't find what you were looking for? Find more on Obtain Row and Column Information Or get search suggestion and latest updates.




Tagged: