The VBA IsError function returns a Boolean, indicating whether a supplied expression represents an error.
The syntax of the function is:
Where the supplied Expression is the expression that you want to test.
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
var2 = CVErr( 11 ) ' sets var2 to Error 11isErr1 = IsError( var1 ) ' The variable isErr1 is now equal to False. isErr2 = IsError( var2 ) ' The variable isErr2 is now equal to True. |
The above examples show that the IsEmpty function returns: