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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping With Find Statement 1

Status
Not open for further replies.

Los11

Technical User
Aug 5, 2003
3
US
I want to run a loop until Excel cant find anymore cells that match the value i declared. What statement must i use to along with false in order to accomplish this. thanx in advance.
 
Hi Los11,

Off the top of my head I don't think Excel Find has anything like Word's .Find.Wrap property and it will loop forever round your worksheet if you let it. What you have to do is note the address of the first cell you find your search string in and compare the rest against it until you get there again which means there are no more.

Enjoy,
Tony
 
This works for me ok

dim find
dim n

find = Worksheets(1).Cells(n, 1).Value
Do While n < 65500
find = Worksheets(1).Cells(n, 1).Value
If find =&quot;123&quot; Then
MsgBox &quot;Found&quot;
endif
n = n + 1
Loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top