Sign in to confirm you’re not a bot
This helps protect our community. Learn more
On Error GoTo, On Error Resume Next, and GoTo 0 in Excel VBA - Code Included
352Likes
46,064Views
2016Jul 6
Grab the Free VBA Quick Reference Guide https://www.chrisjterrell.com/excel-v... On Error enables error-handling within your macro and specifies what will be done in an error occurs. On Error GoTo - sends the code to a specific line On Error Resume Next - just continues to the next line if an error occurs. And there is no Debug window if there is a runtime error. On Error GoTo 0 - Resets the error handler and will show the Debug form if an error occurs. Code: ================ Sub ErrorMod() On Error GoTo errHandler d = 0 'On Error Resume Next 'On Error GoTo 0 If 0 / d = True Then MsgBox "You did it" End If Exit Sub errHandler: Debug.Print Err.Description 'MsgBox "Error" d = 1 'Resume - Will go back to the line of code that the error occured on and try to run it again 'Resume 'Resume Next - Will continue the Code but go to the next line Resume Next End Sub

Follow along using the transcript.

EverydayVBA

11.5K subscribers