![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
Hello people
Do you know what's the syntex to return the row number of the selected cell in excel by using VB ? |
|
|
|
#2 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
How's this:
Sub rowNum() ActiveCell = ActiveCell.Row End Sub Cheers, Nate |
|
|
|
|
|
#3 |
|
Guest
Posts: n/a
|
One more question
what should I put if I need the row number of a cell which is NOT SELECTED? |
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Allentown, PA
Posts: 2,510
|
How would we know what row that is?
__________________
~Anne Troy |
|
|
|
|
|
#5 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
You mean like a test? You could do something like the following:
Sub rowNum() myRange = ActiveCell.Row If myRange <> 2 Then 'row 2 for expample MsgBox ("Smarten' Up") 'Procedure if True Else: MsgBox ("Well Done") 'Procedure if False End If End Sub HTH. Cheers, Nate [ This Message was edited by: NateO on 2002-03-04 11:09 ] |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|