VBA IsMissing Function

VBA IsMissing Function in Excel

VBA IsMissing function in Excel is categorized as an Information function in VBA. It is a built-in function in MS Office Excel VBA. Checks specified an optional argument is missing or not. It has one input parameter. It returns a Boolean value (True or False). If specified optional argument is empty then it returns True, Otherwise it returns False.

We can use this function as a worksheet function and also used in VBA. This function can be use in either procedure or function in a VBA editor window in Excel. We can use this VBA IsMissing function any number of times in any number of procedures or functions. In the following section we learn what is the syntax and parameters of the IsMissing function, where we can use this VBA IsMissing function and real-time examples.

Syntax of VBA IsMissing Function<

The syntax of the VBA IsMissing function in Excel

IsMissing(ArgName)

The VBA IsMissing function returns Boolean value either True or False. If ArgName argument is left blank then, it returns True.
Note: This function only works for Variant data type variables.This function cannot be applied for data types like Boolean, Integer, Double, Date, etc. These type of variables initialized automatically. equivalent values. Please find below examples for better understand.

Parameters or Arguments

The IsMissing function has one input parameter or argument.
Where
ArgName: It is a required parameter. The ArgName is an optional argument that you want to evaluate.

Where we can apply or use VBA IsMissing Function?

We can use this VBA IsMissing function in MS Office 365, MS Excel 2016, MS Excel 2013, 2011, Excel 2010, Excel 2007, Excel 2003, Excel 2016 for Mac, Excel 2011 for Mac, Excel Online, Excel for iPhone, Excel for iPad, Excel for Android tablets and Excel for Android Mobiles.

Example 1: Check an optional argument (variant) is missing or not

Here is a simple example of the VBA IsMissing function. This below example checks the for the optional argument is missing or not. The output of below macro is TRUE.

'Check an optional argument (variant data type) is missing or not
Sub VBA_IsMissing_Function_Ex1(Optional iArgument As Variant)
    
    'Variable declaration
    Dim sOutput As Boolean
    
    sOutput = IsMissing(iArgument)
   
    'Display output message
    MsgBox "The optional argument is missing or not : " & sOutput, vbInformation, "VBA IsMissing Function"
    
End Sub

Output: Here is the screen shot of the first example output.

Example 2: Check an optional argument(Boolean) is missing or not

Here is a another example of the VBA IsMissing function. This below example checks for the optional argument is missing or not.

'Check an optional argument(Boolean data type) is missing or not
Sub VBA_IsMissing_Function_Ex2(Optional iArgument As Boolean)
    
    'Variable declaration
    Dim sOutput As Boolean
    
    sOutput = IsMissing(iArgument)
   
    'Display output message
    MsgBox "The optional argument is missing or not : " & sOutput, vbInformation, "VBA IsMissing Function"
    
End Sub

Output: The below specified example macro doesn’t work. Because a Boolean data type default consists of False value.

Example 3: Check an optional argument is provided or not

Here is a simple example of the VBA IsMissing function. This below example checks the for the optional argument is missing or not. Here we have specified function, which is used in the procedure to check argument is missing or not. The output of below macro is TRUE.
User defined Function:

' Function procedure definition.
Function OutputValue(Optional iArgument As Variant)
    If IsMissing(iArgument) Then
        OutputValue = True
    Else
        OutputValue = False
    End If
End Function

Note: The above specified user defined function used in the below procedure.

'Check an optional argument is provided or not
Sub VBA_IsMissing_Function_Ex3()
    
    'Variable declaration
    Dim sOutput As Boolean
    
    sOutput = OutputValue()
       
    'Display output message
    MsgBox "The optional argument is missing or not : " & sOutput, vbInformation, "VBA IsMissing Function"
    
End Sub

Output:Here is the screen shot of the third example output.

Instructions to Run VBA Macro Code or Procedure:

You can refer the following link for the step by step instructions.

Instructions to run VBA Macro Code

Other Useful Resources:

Click on the following links of the useful resources. These helps to learn and gain more knowledge.

VBA Tutorial VBA Functions List VBA Arrays in Excel Blog

VBA Editor Keyboard Shortcut Keys List VBA Interview Questions & Answers

1 thought on “VBA IsMissing Function in Excel”

Leave a Reply