help with on error stuff

  • Thread starter Thread starter Matthew Dyer
  • Start date Start date
M

Matthew Dyer

I want my code to stop altogether when it hits this particular error.
I'm thinking it might be easiest to do the on error <label>, and call
a seperate sub/function to quit out of the macro, so here's what I've
got so far:

On Error GoTo file_error:
foldername = MyPath & Format(Now, "mm-dd-yyyy") & "\"
MkDir foldername

file_error:
MsgBox "The Save To Directory Does Not Exist", vbOKOnly
Call macro_quit

What code would I put into macro_quit to quit our of the entire
process? Is there a code I could put in the file_error label and skip
the macro_quit call altogether?
 
I want my code to stop altogether when it hits this particular error.
I'm thinking it might be easiest to do the on error <label>, and call
a seperate sub/function to quit out of the macro, so here's what I've
got so far:

    On Error GoTo file_error:
    foldername = MyPath & Format(Now, "mm-dd-yyyy") & "\"
    MkDir foldername

file_error:
        MsgBox "The Save To Directory Does Not Exist", vbOKOnly
        Call macro_quit

What code would I put into macro_quit to quit our of the entire
process? Is there a code I could put in the file_error label and skip
the macro_quit call altogether?

Figured it out! used an additional ExitHere label with the Exit Sub
command

On Error GoTo file_error:
foldername = MyPath & Format(Now, "mm-dd-yyyy") & "\"
MkDir foldername

file_error:
MsgBox "The 'Save To Directory' in Worklist Detail Format Does
Not Exist!", vbOKOnly
Resume ExitHere
ExitHere:
Exit Sub
 
Without knowing what you have done so far..........

file_error:
MsgBox "The Save To Directory Does Not Exist", vbOKOnly
Exit Sub

You may have to reset things like screenupdating and calculation mode etc
before the Exit Sub


Gord Dibben MS Excel MVP
 
Back
Top