Загрузка страницы

On Error GoTo, On Error Resume Next, and GoTo 0 in Excel VBA - Code Included

Grab the Free VBA Quick Reference Guide
https://www.chrisjterrell.com/excel-vba-quick-reference-guide/
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

Видео On Error GoTo, On Error Resume Next, and GoTo 0 in Excel VBA - Code Included канала EverydayVBA
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
6 июля 2016 г. 21:37:01
00:08:40
Яндекс.Метрика