View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
John John is offline
external usenet poster
 
Posts: 2,069
Default Stopping Find from wrapping around in code?

Hi Peter,
thanks for feedback & good point about hidden columns.
--
jb


"Peter T" wrote:

I tried your example exactly as posted with some 2's in column A on the
second sheet. It worked fine for me (though it wouldn't if the column was
hidden)

Regards,
Peter T

"john" wrote in message
...

someone correct me if I am wrong but I believe there is an error with the
code construct of the Find Method help file example (2003)? even if not, I
did have problems with the example and now use modified version as

follows.

Dim c As Range
Dim FirstAddress As String
With Worksheets(2).Range("a1:a500")
Set c = .Find(2, LookIn:=xlValues)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
c.Value = 5
Set c = .FindNext(c)
If c Is Nothing Then Exit Do
Loop Until c.Address = FirstAddress
End If
End With


hope of some interest.

--
jb


"Peter T" wrote:

In Help search for "Find Method", then look at the example

Regards,
Peter T

"Maury Markowitz" wrote in message

...
I'm using Find to loop through column ET on my sheet and find all the
"2"s. I stop the search when the .Row of the last .FindNext is past
the last row of the sheet.

But it never is. That's because when it actually does find the last
one, the next .FindNext wraps back to the top of the column again!

Is there some way to stop it? The Help doesn't seem to suggest a
solution.

Maury