Excel VBA IsMissing Function

VBA IsMissing Function: The IsMissing function in VBA checks if any parameter to a procedure is missing or not. It returns a Boolean value True if the specified parameter has not been provided and returns False if the argument has been supplied.

Syntax

IsMissing (ArgName)

Parameter

ArgName (required)- This parameter represents the name of the argument that you want to check.

Return

This function returns a Boolean value True if the specified parameter has not been provided and returns False if the argument has been supplied.

Example 1

Sub IsMissing_Example1(Optional var As Variant)
 'var is not been initialized
 Is_Missing = IsMissing(var)
 Cells(1, 1).Value = "The var is missing "
 'the function will return true
 Cells(1, 2).Value = Is_Missing
 End Sub 

Output

The var is missing TRUE
VBA IsMissing Function

Example 2

Sub IsMissing_Example2(Optional var As Variant)
 var = 1
 'var is not been initialized
 Is_Missing = IsMissing(var)
 'the Is_Missing will return True as var is initializied with 1
 If Is_Missing = True Then
     MsgBox ("Our argument is missing!")
 Else
     MsgBox (var)
 End If
 End Sub 

Output

VBA IsMissing Function