ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Displaying error messages (https://www.excelbanter.com/excel-programming/275554-re-displaying-error-messages.html)

Chip Pearson

Displaying error messages
 
Will,

You can trap for the error, and display the error message in your error
handling block. E.g,

Sub Test()
On Error GoTo ErrHandler:
'
' your code here
'
Exit Sub
ErrHandler:
MsgBox "The following error occured: " & vbCrLf & _
Err.Number & " - " & Err.Description
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com



"Will" wrote in message
...
Hi Folks

My apologies if this has been posted before - does anyone
know of any code which I could use to display an error
message instead of the dreaded 'debug error' box?

I am able to display a message box which alerts the user
to the fact that an error has occured - can I show the
error within this message box?

Any help appreciated.

Thanks in advance.
Will




Will[_5_]

Displaying error messages
 
Thanks for that Chip, it worked a treat.

Regards
Will
-----Original Message-----
Will,

You can trap for the error, and display the error message

in your error
handling block. E.g,

Sub Test()
On Error GoTo ErrHandler:
'
' your code here
'
Exit Sub
ErrHandler:
MsgBox "The following error occured: " & vbCrLf & _
Err.Number & " - " & Err.Description
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com



"Will" wrote in message
...
Hi Folks

My apologies if this has been posted before - does

anyone
know of any code which I could use to display an error
message instead of the dreaded 'debug error' box?

I am able to display a message box which alerts the user
to the fact that an error has occured - can I show the
error within this message box?

Any help appreciated.

Thanks in advance.
Will



.



All times are GMT +1. The time now is 05:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com