Search notes:

VBA statement: resume

Resume execution after an error was handled and clears the err object.
resume next
resume LABEL

Skipping a specific error

The following example tries to demonstrate how a specific error (here: a division by zero error) can be skipped by using resume next in the error handler (that was established with on error goto ….
option explicit

sub main () ' {
   skipDivisionError
end sub ' }

sub skipDivisionError() ' {
  on error goto err_

    dim res(-3 to 2) as double

    dim i as long
    for i = -3 to 3
       res(i) = 5 / i
       debug.print i
    next i

    exit sub

  err_:

    if err.number = 11 then ' 11: Division by zero
       debug.print("Skipping division by zero error")
       resume next
    end if

    debug.print ("Not skipping " & err.description & " " & err.number)

end sub ' }
Github repository about-VBA, path: /language/statements/resume/skip-error.bas

See also

error handling
The on error statement.
VBA statements

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758201510, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/VBA/language/statements/resume/index(84): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78