![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Chicago, IL USA
Posts: 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?
|
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
How about something simple like:
On Error GoTo 1 1 MsgBox "Error has occurred"
__________________
Kind regards, Al Chara |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: Chicago, IL USA
Posts: 306
|
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 |
|
|
|
|
|
#4 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Placement is key:
Code:
Sub examp() On Error GoTo 1 'your code here Exit Sub 1 MsgBox "Error has occurred" End Sub _________________ Cheers, NateO [ This Message was edited by: NateO on 2002-04-03 08:30 ] |
|
|
|
|
|
#5 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
Forgot some lines, use the following setup:
Sub YourMacro() On Error GoTo 1 'insert your code 1 MsgBox "Error has occurred" End Sub
__________________
Kind regards, Al Chara |
|
|
|
|
|
#6 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
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, NateO [ This Message was edited by: NateO on 2002-04-03 08:57 ] |
|
|
|
|
|
#7 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
Good point, NateO.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|