Search notes:

VBA statement: on error resume next

After setting on error resume next, erroneous statements don't cause the program to aborted, rather, the VBA interpreter will execute (resume) the next statement.
When an error occurs, the error number is recorded in err.number, a textual description of the error in `err.description. Methods to clear the err object are described here.
option explicit

sub main ' {
    divideByZero
end sub ' }

sub divideByZero ' {
   on error resume next

   dim num as long
   dim res as long
   for num = -3 to 3
       res = 5 / num
       debug.print("res = " & res & ", err.number = " & err.number & ", err.description = " & err.description)
   next num

end sub ' }
Github repository about-VBA, path: /language/statements/on-error/resume-next.vb

See also

on error.

Index