On Error Goto 0 not resetting error trapping

2020-03-15 07:08发布

I was under the impression that On Error GoTo 0 reset error handling.

So why does On error resume next not seem to be registering in the following?

Sub GetAction()
Dim WB As Workbook
Set WB = ThisWorkbook

On Error GoTo endbit:
'raise an error
Err.Raise 69
Exit Sub
endbit:
On Error GoTo 0 '<<<reset error handling?

On Error Resume Next
WB.Sheets("x").Columns("D:T").AutoFit
MsgBox "ignored error successfully and resumed next"    

End Sub

1条回答
ら.Afraid
2楼-- · 2020-03-15 07:31

You need to use On Error GoTo -1 or Err.Clear to reset error trapping.

Check this answer I posted a few months ago for a more detailed explanation.

查看更多
登录 后发表回答