The VBA IsEmpty Function

Description

The VBA IsEmpty function returns a Boolean, indicating whether a supplied Variant is Empty (i.e. has been set to the value Empty or has not been declared).

The function returns True if the supplied Variant is empty and returns False otherwise.

The syntax of the IsEmpty function is:

IsEmpty( Expression )

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


VBA IsEmpty Function Examples

The following code provides three different variants to the VBA IsEmpty function.

' Test if three different Variants are empty.
Dim var1 As Variant
Dim var2 As Variant
Dim isEmp1 As Boolean
Dim isEmp2 As Boolean
Dim isEmp3 As Boolean
var1 = 0
isEmp1 = IsEmpty( var1 )
' The variable isEmp1 is now equal to False.
var2 = Empty
isEmp2 = IsEmpty( var2 )
' The variable isEmp2 is now equal to True.
isEmp3 = IsEmpty( var3 )
' The variable isEmp3 is now equal to True.

The above examples show that the IsEmpty function returns: