On Error reset?

P

PCLIVE

I'm using the On Error Goto code (see below).

On Error GoTo StopError

The StopError routine is as follows:

StopError:
Msg = "There appears to be no data for this model. (" & model & ")
Click OK to continue and then verify that there were no calls for that
particular model last month." ' Define message.
Style = vbOKOnly ' Define buttons.
Title = model ' Define title.
Response = MsgBox(Msg, Style, Title)
GoTo Repeat


This macro loops several times. Each time, I need to be able to keep the
"On Error GoTo StopError" active. For some reason, the second time an error
occurs, I just get the error instead of the code re-routing to the StopError
routine. I've tried adding "On Error Goto 0" before the "GoTo Repeat"
statement with no success.

Any ideas?
 
R

Rob Bovey

GoTo doesn't deactivate an error handler. Change the last line in your
error handler to:

Resume Repeat

Resume deactivates the error handler and branches code execution to the line
specified by the label.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *
 
P

PCLIVE

Thanks, that works great!


Rob Bovey said:
GoTo doesn't deactivate an error handler. Change the last line in your
error handler to:

Resume Repeat

Resume deactivates the error handler and branches code execution to the line
specified by the label.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top