On Error GOTO Quit

Guzzlr

Well-known Member
Joined
Apr 20, 2009
Messages
930
Office Version
  1. 2016
Platform
  1. Windows
Code:
On Error GoTo Quit:

Code:
Quit:
MsgBox ("Please Add Data to Template Sheet" _
& vbNewLine & "Then Run Program")


Hello All,
I have the above code. The On Error GoTo Quit is at the top of the code, with the Quit: at the bottom. The problem is my message box keeps popping up, even when no errors are happening?
What am I doing wrong?
Thanks
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Code:
On Error GoTo Quit:

Code:
Quit:
MsgBox ("Please Add Data to Template Sheet" _
& vbNewLine & "Then Run Program")


Hello All,
I have the above code. The On Error GoTo Quit is at the top of the code, with the Quit: at the bottom. The problem is my message box keeps popping up, even when no errors are happening?
What am I doing wrong?
Thanks

You have to put End Sub or End Function (depending on what type of code procedure you have) immediately before the Quit: label to stop your code from falling through.
 
Upvote 0
It is likely that some other error is happening and you are not viewing it.


It is not recommended to use: On Error GoTo


It is advisable to try to control each of the errors.


If you like, put all your code here to review it and adjust the code to control errors.
 
Upvote 0
You need to exit the sub, before the Quit, like
Code:
Exit Sub
Quit:
MsgBox ("Please Add Data to Template Sheet" _
& vbNewLine & "Then Run Program")
I would also advise against using VBA keywords (like Quit) for variables, GoTos etc.
 
Upvote 0
thank you all...it's working now. I got rid of the word "Quit" and used ErrHandler instead
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,212,927
Messages
6,110,724
Members
448,294
Latest member
jmjmjmjmjmjm

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top