我的印象是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 -1
或Err.Clear
重置错误陷阱。
请检查我几个月前发布的this answer,以获得更详细的说明。