VBA error handling on error resume next

Source: Internet
Author: User

Http://vbaexcel.eu/vba-macro-code/vba-error-handling-on-error-resume-next

 

 

This macro code enables the on error resume next function.

Explanation

To enable on error resume next will make the VBA program skip code that generates an error and normally stops the program.

A basic example file of the VBA macro is available for download at the bottom of this web page, or just copy and paste the Code directly from this page.
In your cases it is done clever to enable the on error resume next function because the bugs in your code will not be easily found. however in some cases when you know that there might appear an error that you want the program to ignore you can disable or enable the function. after the program has run the code lines that is relevant for the problem make sure to enable the function again.

 

Code

Public sub error_handling_vba_on_error_resume_next ()

'The error function is turned off in case of error just continue
On Error resume next

'A error statment is trying to be executed and no error occurs due to on error resume next
Test = 5/0.

'Normal error handling is turned on again
On Error goto 0

End sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.