Error trapping & Handling

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to do the following;

I want to close without saving all open workbooks that are currently opn and
happen to match a list in an array.

I want to "On Error" drop out of an If then or for ..next loop. How the hell
do I accomplish this(I've tried 6 ways to sunday)

I Want to elegantly deal with things like "Worksheet exists" or "Note in
cell already exists"

Thanks in advance I've looked around using Google but I have had no success.
Nobody seems to be interested in errors or giving away the secrets to us Yobs!

Jeff
 
You can drop out of an If-Then construct with a GoTo and a label. You get
out of a For loop with "Exit For".
With the On Error, you can say something like:
On Error GoTo TheOtherPlace. Immediately after the TheOtherPlace label, put
"On Error GoTo 0" to reset the error system. Post back if you need more.
HTH Otto
 
Your subs and or functions should look like this...

private sub test()
On Error Goto ErrorHandler

'Your code here...

Exit Sub
ErrorHandler:
'Do that voodoo that you do
'Resume Next 'go back to the last line of regular code executed and
continue at the following line
end sub
 
Otto, for the "On Error GoTo TheOtherPlace", what is the other place? Is it a
line number or another statement?

Jeff
 

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

Similar Threads

Set Error handling INSIDE error-trap 6
Error Trapping 6
error trap/handler placement 2
Error trapping 4
placement of error traps 2
VBA Error Handling 4
Error Trapping 3
Error Trapping Issues 8

Back
Top