Excel 2016 vba and macros 16
We use error handling to deal with runtime errors. To understand error handling we must first understand the different types of errors in VBA. They allow our application to deal gracefully with any errors we weren’t expecting. This is where the VBA error handling statement comes into play. If we think an error is likely to occur at some point, it is good practice to write specific code to handle the error if it occurs and deal with it.įor all other errors, we use generic code to deal with them. These errors are normally caused by something outside your control like a missing file, database being unavailable, data being invalid etc.
Excel 2016 vba and macros 16 archive#
( Note: Archive members have access to the webinar archive.)Įrror Handling refers to code that is written to handle errors which occur when your application is running. Members of the Webinar Archives can access the webinar for this article by clicking on the image below. Returns the error text from an error number. You can populate this when you use Err.Raise.Ī function that allows you to generate your own error. (Only useful if you need to check a specific error occurred.)
When an error occurs the error information is stored here.
Goes to a specific label when an error occurs. When error occurs, the code stops and displays the error.Ĭlears the current error setting and reverts to the default.