Thread: FindNext Errors
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Geoff Geoff is offline
external usenet poster
 
Posts: 371
Default FindNext Errors

Hi Leith
I don't think that can be.
If you enter 2 in several rows of col A they are all changed to 5 correctly.
The error occurs when no more 2's are found in the range and c becomes
nothing.
How can Nothing have an address is what I cannot fathom.

Geoff

"Leith Ross" wrote:

On Apr 26, 8:52 am, Geoff wrote:
I simply cannot get the Help example on FindNext to work. Even explicitly
setting the find paramaeters still results in err 91. The example cell value
is changed but then errors out at Loop While.

The problem seems to be with c.address. What am I missing?

With Worksheets(1).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)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

Geoff


Hello Geoff,

You first Find is looking for the number 2. The FindNext is looking
for a 5. If you are searching for all 5's, change the 2 in the first
Find call to a 5,

Sincerely,
Leith Ross