Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: row number

  1. #1
    Guest

    Default

    Hello people
    Do you know what's the syntex to return the row number of the selected cell in excel by using VB ?

  2. #2
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    How's this:

    Sub rowNum()
    ActiveCell = ActiveCell.Row
    End Sub

    Cheers, Nate

  3. #3
    Guest

    Default

    One more question
    what should I put if I need the row number of a cell which is NOT SELECTED?

  4. #4
    MrExcel MVP Anne Troy's Avatar
    Join Date
    Feb 2002
    Location
    Westwood NJ
    Posts
    2,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    How would we know what row that is?
    ~Anne Troy

  5. #5
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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 ]

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •