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

Become an Σxpert at Σxcel.com

 


err

Err is a system variable that contains 0 if no error or an error number.

The value is reset by the On Error Resume Next statement


On Error Resume Next

' do something

If Err <> 0 then
   'handle the error
End If

Some commonly occurring errors are:
  • 9 Subscript out of range
  • 5 Invalid Procedure call
  • 53 File not found
  • 75 Directory Already Exists
  • 1004 - Application-defined or object-defined error
  • 40040 - weird but skipping it and code still worked

    Immediate Window Ctrl G


    err = 7:? error

    for i = 1 to 300:if instr(error(i),"Application-defined") > 0 then ? i,error(i):next



    try the following code to view all errors:

    sub show_errors()

    for i = 1 to 1000
      if instr(error(i), "Application-defined") = 0 then Debug.print i, Error(i)
    next

    End Sub




    Related Statements:
  • On Error Resume Next
  • Err.Raise
  • Error
  • Err.Description
  • On Error Goto label
  • Resume
  • Resume Next
  • resume label
  • Msgbox err & " " & Error
  • Error(x)
  • If Err <> 0 then stop
  • Error 2015
  • IsError( )
  • Err(Abs())

  •