findnext question
ok, thanks to both for the explanation. so, in the help example for findnext, is
"Loop While Not c Is Nothing And c.Address < firstAddress"
needed? it's changing 2 to 5, so i would think that line isn't needed, either.
--
Gary
"Dave Peterson" wrote in message
...
This line from VBAs help:
Loop While Not c Is Nothing And c.Address < firstAddress
will blow up if c is nothing (since c.address will return an error).
If you weren't removing the seached value, then the .findnext() would loop
until
it got to the first found cell and never be nothing.
Gary Keramidas wrote:
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
--
Dave Peterson
|