Link to home
Start Free TrialLog in
Avatar of peteryau
peteryauFlag for Hong Kong

asked on

marcro to assign a variable to the row number of a cell contains a particular word

HI
I want to assign an variable  in excel marco which returns  the row number of a cell in Colume A with the word "find_me".  The word "find_me only exist one time in column A.
How can I do it?

Thanks
Peter
Avatar of andrewssd3
andrewssd3
Flag of United Kingdom of Great Britain and Northern Ireland image

Does the cell consist only of the word "find_me", or does it just contain the word, like "can you find_me in this cell".  Are you worried about upper or lower case?
Avatar of Saqib Husain

activesheet.range("A:A").find("find_me").row
Avatar of TinTombStone
TinTombStone

A simple solution

Dim foundRow As Long

    Cells.Find("find_me", Range("A1"), , xlByColumns).Activate

    foundRow = ActiveCell.Row

    MsgBox foundRow

Open in new window

Although ssagibh's solution is simpler and better.  I always forget the really easy methods!
Avatar of peteryau

ASKER

Yes, the word find_me is case sensitive and only of the word "find_me"
how to show the row number  which has exactly the value "find_me"?
ssagibh's solution shows the row number of "find_me_too"  which occurs before "find_me"
activesheet.range("A:A").find("find_me",,,xlwhole).row
ASKER CERTIFIED SOLUTION
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial