M
Matt
Hello,
I've always had a hard time understanding the find and findnext
methods so to test I copied the code presented in the help file to my
worksheet and ran the code.
Oddly the code generated an error message 91 "Object variable or with
block variable not set". I've never had a situation where the VBA Help
code creates an error message..so I'm kind of lost at figuring it out
Any guidance would be appreciated. Thanks, Matt
Here's the code:
Sub another_find()
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
End Sub
I've always had a hard time understanding the find and findnext
methods so to test I copied the code presented in the help file to my
worksheet and ran the code.
Oddly the code generated an error message 91 "Object variable or with
block variable not set". I've never had a situation where the VBA Help
code creates an error message..so I'm kind of lost at figuring it out
Any guidance would be appreciated. Thanks, Matt
Here's the code:
Sub another_find()
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
End Sub