Error 20, “Resume without error”, means a Resume or Resume Next executed when VBA was not actually handling an error. Resume is only legal inside an active error handler; when execution wanders into the handler without an error occurring, the first Resume it meets raises error 20. Like error 3, it is a control-flow structure bug, and the trigger is almost always a missing Exit Sub before the handler label.
Sub Import()
On Error GoTo Handler
' ... work ...
Exit Sub ' without this, success falls into the handler
Handler:
MsgBox Err.Description
Resume Next ' error 20: no error is active on fall-through
End Sub
GoTo into the handler from normal code produces the same problem; handlers are entered only by the error mechanism.If the layout is correct and error 20 still appears, look for a Resume executed after Err.Clear was called in the same handler, or a nested call: the procedure was invoked from another handler, completed, and the Resume in the outer code then has no active error of its own. Trace the call stack when it fires.
What is the difference between error 3 and error 20? Both are fall-through bugs. Error 3 is a Return reached without a GoSub; error 20 is a Resume reached without an active error. Both are fixed by controlling flow into the block, usually with Exit Sub.
Can Resume Next at the top of a procedure cause error 20? On Error Resume Next is a directive, not the Resume statement, and cannot raise error 20. Only an executed Resume or Resume label statement outside an active handler does.