LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Error when running VBA Help's Find method example

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Error handling with the Find Method ExcelMonkey Excel Programming 5 May 28th 08 09:05 PM
Type mismatch error in Find method JLGWhiz Excel Programming 1 April 9th 07 03:51 AM
Error when use find method in vb6 Kay[_5_] Excel Programming 0 May 11th 06 01:02 AM
Error Trapping the Find method big t Excel Programming 2 October 24th 05 01:39 PM
Run Time error '1004' when running Calculation method Simon P[_2_] Excel Programming 1 January 5th 04 12:32 PM


All times are GMT +1. The time now is 12:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"