I
IanKR
When I run the Find method example from the VBA Help I get:
"Run-time error '91': Object variable or With block variable not set"
viz:
Sub Test()
With Worksheets(1).UsedRange
Set c = .Find("Ian", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = "Tom"
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
End Sub
It replaces all the "Ian"s that it finds with "Tom"s, but presumably once it
has replaced the last one (i.e. once c eventually becomes Nothing, and
therefore c.Address doesn't exist) it fails. I think that is the
explanation, because it works without an error if I remove the
And c.Address <> firstAddress
from the end of the Loop While line, so I'm doing it like that in my
project. Is this an example of VBA Help giving duff information? In which
case, not only is the removed bit surplus to requirements, but also wrong?!
Thanks
Ian
"Run-time error '91': Object variable or With block variable not set"
viz:
Sub Test()
With Worksheets(1).UsedRange
Set c = .Find("Ian", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = "Tom"
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
End Sub
It replaces all the "Ian"s that it finds with "Tom"s, but presumably once it
has replaced the last one (i.e. once c eventually becomes Nothing, and
therefore c.Address doesn't exist) it fails. I think that is the
explanation, because it works without an error if I remove the
And c.Address <> firstAddress
from the end of the Loop While line, so I'm doing it like that in my
project. Is this an example of VBA Help giving duff information? In which
case, not only is the removed bit surplus to requirements, but also wrong?!
Thanks
Ian