我的印象是On Error GoTo 0重置了错误处理。

那么,为什么On error resume next在下面似乎没有注册?

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

最佳答案

您需要使用On Error GoTo -1Err.Clear重置错误陷阱。

请检查我几个月前发布的this answer,以获得更详细的说明。

10-05 21:19
查看更多