By using expertatexcel.com you agree to our cookie policy, We and our partners operate globally and use cookies, for multiple purposes

expertatexcel.com

 


On Error Goto ErrHandler

This statement is one way to handle errors in VBA


Sub test_OnError()
dim i as integer

for i = 1 to 100000 step 1000
    debug.Print i
next
err.raise 2292

Exit Sub
ErrHandler:
  MsgBox err & " " & error & " " & err.linenumber

  stop
  resume next
  resume

End Sub