+ Reply to Thread
Results 1 to 3 of 3

"on error resume next" NOT working...

  1. #1
    Chris M
    Guest

    "on error resume next" NOT working...

    Hi...
    I have a macro which at some point deletes a particular worksheet. In case
    the worksheet does NOT exist, I have placed an "on error..." command to allow
    the macro to keep running... My problem: the code used to work... and now it
    doesn't! I get a "subscript out of range" error. Why isn't the "on error"
    routine working here? Any suggestions on fixing this? Here's my code:

    'if the "Final Report" sheet exists, delete it.
    On Error Resume Next
    Application.DisplayAlerts = False
    Worksheets("Final Report").Delete
    Application.DisplayAlerts = True
    'more code here...

    In another macro, if a given worksheet does NOT exist, my on error routine
    is supposed to direct the execution to finish up, etc.... Here, as well, I
    get the "subscript out of range" error... Again, the on error is NOT working
    to get me past the error...

    Any ideas are greatly appreciated!

    --
    Chris M

  2. #2
    Tom Ogilvy
    Guest

    Re: "on error resume next" NOT working...

    What options do you have in the VBE under Tools=>Options. Do you have break
    on unhandled errors selected?

    --
    Regards,
    Tom Ogilvy

    "Chris M" <[email protected]> wrote in message
    news:[email protected]...
    > Hi...
    > I have a macro which at some point deletes a particular worksheet. In

    case
    > the worksheet does NOT exist, I have placed an "on error..." command to

    allow
    > the macro to keep running... My problem: the code used to work... and now

    it
    > doesn't! I get a "subscript out of range" error. Why isn't the "on

    error"
    > routine working here? Any suggestions on fixing this? Here's my code:
    >
    > 'if the "Final Report" sheet exists, delete it.
    > On Error Resume Next
    > Application.DisplayAlerts = False
    > Worksheets("Final Report").Delete
    > Application.DisplayAlerts = True
    > 'more code here...
    >
    > In another macro, if a given worksheet does NOT exist, my on error routine
    > is supposed to direct the execution to finish up, etc.... Here, as well, I
    > get the "subscript out of range" error... Again, the on error is NOT

    working
    > to get me past the error...
    >
    > Any ideas are greatly appreciated!
    >
    > --
    > Chris M




  3. #3
    Chris M
    Guest

    Re: "on error resume next" NOT working...

    Thanks Tom... the option was set to "break on all errors". After setting
    this to "Break on unhandled errors", the macro which looks for a sheet to
    delete works fine now.

    HOWEVER... the 2nd macro that attempts to activate a given worksheet for
    processing still breaks if the given worksheet does not exist. Here's some
    code:

    On Error GoTo AllSheetsDone
    Sheets("Day 1").Select
    Call MARKfirstAVG
    Call getAVERAGE
    Call getSTDEV

    On Error GoTo AllSheetsDone
    Sheets("Day 2").Select
    Call MARKfirstAVG
    Call getAVERAGE
    Call getSTDEV

    On Error GoTo AllSheetsDone
    Sheets("Day 3").Select
    Call MARKfirstAVG
    Call getAVERAGE
    Call getSTDEV

    If, for example the file only has Day 1 and Day 2 sheets, the "on error"
    routine is supposed to go to the AllSheetsDone label. Even with the option
    "Break on unhandled errors" set now, it's still breaking when the code
    doesn't find Day 3. What am I missing here?

    Thanks for all your help!
    --
    Chris M


    "Tom Ogilvy" wrote:

    > What options do you have in the VBE under Tools=>Options. Do you have break
    > on unhandled errors selected?
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Chris M" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi...
    > > I have a macro which at some point deletes a particular worksheet. In

    > case
    > > the worksheet does NOT exist, I have placed an "on error..." command to

    > allow
    > > the macro to keep running... My problem: the code used to work... and now

    > it
    > > doesn't! I get a "subscript out of range" error. Why isn't the "on

    > error"
    > > routine working here? Any suggestions on fixing this? Here's my code:
    > >
    > > 'if the "Final Report" sheet exists, delete it.
    > > On Error Resume Next
    > > Application.DisplayAlerts = False
    > > Worksheets("Final Report").Delete
    > > Application.DisplayAlerts = True
    > > 'more code here...
    > >
    > > In another macro, if a given worksheet does NOT exist, my on error routine
    > > is supposed to direct the execution to finish up, etc.... Here, as well, I
    > > get the "subscript out of range" error... Again, the on error is NOT

    > working
    > > to get me past the error...
    > >
    > > Any ideas are greatly appreciated!
    > >
    > > --
    > > Chris M

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1