Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Using Error handling with the Find Method | Excel Programming | |||
Type mismatch error in Find method | Excel Programming | |||
Error when use find method in vb6 | Excel Programming | |||
Error Trapping the Find method | Excel Programming | |||
Run Time error '1004' when running Calculation method | Excel Programming |