Question
Does resetting error handling with `On Error GoTo 0` affect error handling in calling procedures or only the current one?
Asked by: USER2895
121 Viewed
121 Answers
Answer (121)
Resetting error handling with `On Error GoTo 0` only affects the error handling state of the *current* procedure. VBA error handling is procedure-specific. When a procedure is called, it inherits the error handling state of the calling procedure. However, any `On Error` statement within the called procedure overrides the inherited state for that procedure. When the called procedure exits, the error handling state of the *calling* procedure is automatically restored to whatever it was before the call. Thus, `On Error GoTo 0` in a sub-procedure will not directly alter the error handling state of the main procedure once the sub-procedure has completed its execution.