View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default findnext question

Hi Gary,

In your example you replace the search string in each found cell, so
eventually the search string will not be found and rngFound = (ie Is)
nothing. If you comment your replace line your code would run continuously
looping back to the first found(assuming a found) unless you amend to
something similar to the help example.

Regards,
Peter T

"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
in the help, they use firstaddress = c.address so the code doesn't loop
continuously

if i use similar, it generates an error, but my code seems to run fine,

what's
the difference?

With ws.Range("C1:C" & lastRow)
Set rngFound = .Find(What:="<", LookIn:=xlValues)
Do
If Not rngFound Is Nothing Then
rngFound.Value = Replace(Replace(rngFound.Value, "<", "-", 1),

"",
_
"")
rngFound.NumberFormat = "#,##0_);[Red](#,##0.00)"
Set rngFound = .FindNext(rngFound)
End If
Loop While Not rngFound Is Nothing
End With


--


Gary