The VBA IsError Function

Description

The VBA IsError function returns a Boolean, indicating whether a supplied expression represents an error.

The syntax of the function is:

IsError( Expression )

Where the supplied Expression is the expression that you want to test.


VBA IsError Function Examples

The following VBA code uses the IsError function to test whether two variables are errors or not.

' Test if two different expressions represent errors.
Dim var1, var2
Dim isErr1 As Boolean
Dim isErr2 As Boolean
var1 = 10   ' sets var1 to the integer 10
isErr1 = IsError( var1 )
' The variable isErr1 is now equal to False.
var2 = CVErr( 11 )   ' sets var2 to Error 11
isErr2 = IsError( var2 )
' The variable isErr2 is now equal to True.

The above examples show that the IsEmpty function returns: