Solved

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

Posted on 2011-09-05
8
321 Views
Last Modified: 2012-05-12
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
0
Comment
Question by:peteryau
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 17

Expert Comment

by:andrewssd3
ID: 36482812
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?
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 36482862

activesheet.range("A:A").find("find_me").row
0
 
LVL 6

Expert Comment

by:TinTombStone
ID: 36482959
A simple solution

Dim foundRow As Long

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

    foundRow = ActiveCell.Row

    MsgBox foundRow

Open in new window

0
 
LVL 6

Expert Comment

by:TinTombStone
ID: 36483054
Although ssagibh's solution is simpler and better.  I always forget the really easy methods!
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:peteryau
ID: 36483108
Yes, the word find_me is case sensitive and only of the word "find_me"
0
 

Author Comment

by:peteryau
ID: 36483128
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"
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 36483134
activesheet.range("A:A").find("find_me",,,xlwhole).row
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 36483149
activesheet.range("A:A").find("find_me",,,xlwhole,,,true).row

will also match the case
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now