Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Find Next" Command 2

Status
Not open for further replies.

NumberCrunchingMonky

Technical User
Feb 5, 2004
30
US
I use the script below to search for names that appear in Column B of an excel worksheet. It's linked to a cell in which the name is typed. It works fine for a single name. However, if there are muliple records with the same name I cannot get it to "find next" when I hit the button a second time. It just stays on it's first "find". How do I build a "find next" condition in the script so the next record down with the same name gets selected?

Thanks.

NCM


Sub CommandButton1_Click()
Set FindIt = ActiveSheet.Range("B3:B" & ActiveSheet.Range("B1000").End(xlUp).Row).Find(Trim(ActiveSheet.Range("F1").Value))
If Not FindIt Is Nothing Then ActiveSheet.Range(FindIt.Address).Select
End Sub
 
There's a nice example in the VBA help files under "FindNext Method" on how do use a "Do. . .Loop" statement to accomplish this.

VBAjedi [swords]
 
Hi
Have a look in the help file under Find. The example in there should be adaptaqble to precisely what you want.

I use it quite often but never remember the precise code!!
;-)

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
The faqs ma'am, just the faqs. Get the best from these forums : faq222-2244
 
SPOOKY!
;-)

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
The faqs ma'am, just the faqs. Get the best from these forums : faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top