Message if macro is unable to run

Adrae

Active Member
Joined
Feb 19, 2002
Messages
306
Does anyone have sample code of how I could replace the normal "debug me" dialog box with an error message of my choosing that would be followed by the macro stopping with no option to debug at that point?
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Thanks. That works for the messgae box, but if the error is just crucial, the macro continues all the way through to the Msg box that says the change was successful.

How can I modify this code so that it diplays the message and then Ends?

Thanks again :)
 
Upvote 0
Placement is key:

Code:
Sub examp()
On Error GoTo 1
'your code here
Exit Sub
1 MsgBox "Error has occurred"
End Sub

Hope this helps.

_________________
Cheers,<font size=+2><font color="red"> Nate<font color="blue">O</font></font></font>
This message was edited by NateO on 2002-04-03 08:30
 
Upvote 0
Forgot some lines, use the following setup:

Sub YourMacro()
On Error GoTo 1
'insert your code
1 MsgBox "Error has occurred"
End Sub
 
Upvote 0
You'll probably want the "exit sub" (like above) too, I think, in the event that the end-user doesn't completely botch your process.

_________________
Cheers,<font size=+2><font color="red"> Nate<font color="blue">O</font></font></font>
This message was edited by NateO on 2002-04-03 08:57
 
Upvote 0

Forum statistics

Threads
1,213,494
Messages
6,113,972
Members
448,537
Latest member
Et_Cetera

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