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

stopping wrap around from find method

Status
Not open for further replies.

Luis939

MIS
Feb 28, 2003
453
US
hi i saw this remark in the help file regarding the find method, but it doesnt tell you how to accomplish this, it says

When the search reaches the end of the specified search range, it wraps around to the beginning of the range. To stop a search when this wraparound occurs, save the address of the first found cell, and then test each successive found-cell address against this saved address.

how can i do this, i tried setting a variable to the address of the activecell (because i copied and pasted that text from another file), but it didnt work, i suppose my syntax is wrong, and im not sure how to test every successive cell against that variable for the address, thanks!
 
Just look at the example in the VBA help file - here it is:

This example finds all cells in the range A1:A500 that contain the value 2 and makes those cells gray.

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Interior.Pattern = xlPatternGray50
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With Rgds
Geoff
&quot;Some cause happiness wherever they go; others whenever they go.&quot;
-Oscar Wilde
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top