On Error Goto -1

confusion123

Active Member
Joined
Jul 27, 2014
Messages
400
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?
 

GTO

MrExcel MVP
Joined
Dec 9, 2008
Messages
6,154
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:

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,178
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
Code:
On Error Goto -1
when is that used?
Short answer: if you're using it, you're probably doing something wrong.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,178
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
@Mark,

It's funny because it's true. ;)
 

GTO

MrExcel MVP
Joined
Dec 9, 2008
Messages
6,154
Not likely, but if I was ever to suddenly have tons o' funds and made it to East Sussex... (y)
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,178
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
You'd be most welcome!
 

Forum statistics

Threads
1,078,252
Messages
5,339,097
Members
399,277
Latest member
Jyoti C

Some videos you may like

This Week's Hot Topics

Top