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

948 Steps to 6 Figures by Learning Excel-VBA and Other Skills



Step 586 - 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

   Table of Contents | Send us your feedback | © 2025 All Rights Reserved | Edit