+ Reply to Thread
Results 1 to 4 of 4

Return ROW number from qa found range

  1. #1
    Mike
    Guest

    Return ROW number from qa found range

    I have the following:

    Columns("A:A").Select
    Selection.Find(What:="Alabama", After:=ActiveCell, LookIn:=xlFormulas,
    lookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
    MatchCase:=False).Activate

    Now want to have a variable equal to the Row number that it finds the text.


  2. #2
    Chip Pearson
    Guest

    Re: Return ROW number from qa found range

    Try something like

    Dim FoundCell As Range
    Dim WhatRow As Long
    Columns("A:A").Select
    Set FoundCell = Selection.Find(What:="Alabama",
    After:=ActiveCell, _
    LookIn:=xlFormulas, lookAt:=xlPart, SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, MatchCase:=False)
    If FoundCell Is Nothing Then
    MsgBox "Not Found"
    Else
    WhatRow = FoundCell.Row
    MsgBox "Found in row: " & WhatRow
    End If



    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "Mike" <[email protected]> wrote in message
    news:[email protected]...
    >I have the following:
    >
    > Columns("A:A").Select
    > Selection.Find(What:="Alabama", After:=ActiveCell,
    > LookIn:=xlFormulas,
    > lookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
    > MatchCase:=False).Activate
    >
    > Now want to have a variable equal to the Row number that it
    > finds the text.
    >




  3. #3
    Ivan Raiminius
    Guest

    Re: Return ROW number from qa found range

    Hi Mike,

    rownumber=activecell.row

    in your case

    Regards,
    Ivan


  4. #4
    JE McGimpsey
    Guest

    Re: Return ROW number from qa found range

    One way:

    Given your existing code:

    nRow = ActiveCell.Row

    Perhaps a better way:

    Dim nRow As Long
    Dim rFound As Range
    Set rFound = Range("A:A").Find( _
    What:="Alabama", _
    After:=Range("A1"), _
    LookIn:=xlFormulas, _
    LookiAt:=xlPart, _
    SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, _
    MatchCase:=False)
    If Not rFound Is Nothing Then
    nRow = rFound.Row
    Else
    MsgBox "'Alabama' was not found in column A"
    End If





    In article <[email protected]>,
    Mike <[email protected]> wrote:

    > I have the following:
    >
    > Columns("A:A").Select
    > Selection.Find(What:="Alabama", After:=ActiveCell, LookIn:=xlFormulas,
    > lookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
    > MatchCase:=False).Activate
    >
    > Now want to have a variable equal to the Row number that it finds the text.


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1