ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Catching an error (https://www.excelbanter.com/excel-programming/284795-catching-error.html)

Shannon

Catching an error
 
I'm trying to implement the try/catch structure that Java
provides in VBA. I want to try a line of code, if it
returns an error, I want to be able to catch it and return
a message box to the user of my program indicating that
they performed an illegal action. I cannot figure out how
to do this, if anyone can help me, I would be very
appreciative.

No Name

Catching an error
 
At the beginning of said code, write the line:

On Error GoTo ErrorCatcher

and include somewhere the label:

ErrorCatcher:

followed by the code too be executed in teh event of an
eror. P.S. It doesn't have to be named "ErrorCatcher."
You can use any valid identifier. - Pikus
-----Original Message-----
I'm trying to implement the try/catch structure that Java
provides in VBA. I want to try a line of code, if it
returns an error, I want to be able to catch it and

return
a message box to the user of my program indicating that
they performed an illegal action. I cannot figure out

how
to do this, if anyone can help me, I would be very
appreciative.
.



All times are GMT +1. The time now is 11:36 PM.

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