Find error
Rather than trap the error, why not intelligently avoid it. See this pseudo
code:
Dim rng as Range, arr as Variant
Dim i as long
arr = Array("John","Bob","Sue","Phil")
for i = lbound(arr) to ubound(arr)
set rng = Nothing
' no activate - assign to a range variable
set rng = columns(1).Find(arr(i), . . . other arguments . . . )
if not rng is nothing then
rng.select
msgbox "found at " & rng.address
else
msgbox arr(i) & " not found"
end if
Next
--
Regards,
Tom Ogilvy
"David" wrote:
Hi Group,
I am doing several Find procedures in a module. I do not always expect to
Find the text so I get a 91 error. The first instance of the error is handled
by an error procedure "On Error GoTo ErrorHandler" where I clear the error
ErrorHandler:
Err.Clear
This is fine, but I am repeating the Find procedure several more times and
can not predict where and when it might fail again. Subsequent failures do
not allow me to use another "On Error GoTo ErrorHandlerTwo", note the
different name. I can not use a Resume Next, becasue on a failure I need to
skip certain code steps, so I want to continue the code after the
ErrorHandler or ErrorHandlerTwo or Three, etc.
Suggestions would be appreciated. It maybe that I have to Dim and Set, but I
am not sure how to do this for each possible instance of a Find failure.
Thanks
--
David
|