Thanks Thanks:  0
Likes Likes:  0
Results 1 to 6 of 6

Thread: On Error Goto -1

  1. #1
    Board Regular
    Join Date
    Jul 2014
    Posts
    400
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default On Error Goto -1

    My error handling tends to be as follows:

    Code:
    On Error Goto Errhandler
    
         ' some code
    
    Continuation:
    
        On Error Goto 0
    
    Exit Sub
    
    Errhandler:
    
        ' do something
    
        Resume Continuation
    
    End Sub
    Is the above good practice?

    I assume putting On Error Goto 0, "switches off" error handling.

    But I've come across (though rarely):

    Code:
    On Error Goto -1
    when is that used?

  2. #2
    MrExcel MVP
    Join Date
    Dec 2008
    Location
    Phoenix, Arizona
    Posts
    6,154
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: On Error Goto -1

    Read Rory's nice explanation Here

    @RoryA:

    This line still kills me: I'm not actually this blurry in real life unless you're drinking with me.

    I just LMAO each time.

    Mark
    Last edited by GTO; Jan 18th, 2017 at 06:33 AM.

  3. #3
    MrExcel MVP
    Moderator
    RoryA's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    32,677
    Post Thanks / Like
    Mentioned
    32 Post(s)
    Tagged
    4 Thread(s)

    Default Re: On Error Goto -1

    Quote Originally Posted by con123 View Post

    Code:
    On Error Goto -1
    when is that used?
    Short answer: if you're using it, you're probably doing something wrong.

  4. #4
    MrExcel MVP
    Moderator
    RoryA's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    32,677
    Post Thanks / Like
    Mentioned
    32 Post(s)
    Tagged
    4 Thread(s)

    Default Re: On Error Goto -1

    @Mark,

    It's funny because it's true.

  5. #5
    MrExcel MVP
    Join Date
    Dec 2008
    Location
    Phoenix, Arizona
    Posts
    6,154
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: On Error Goto -1

    Not likely, but if I was ever to suddenly have tons o' funds and made it to East Sussex...

  6. #6
    MrExcel MVP
    Moderator
    RoryA's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    32,677
    Post Thanks / Like
    Mentioned
    32 Post(s)
    Tagged
    4 Thread(s)

    Default Re: On Error Goto -1

    You'd be most welcome!

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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