Sign in with Microsoft
Sign in or create an account.
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

Returns a Boolean value indicating whether an optional Variantargument has been passed to a procedure.


IsMissing( argname )

The required argname argument contains the name of an optional Variant procedure argument.


Use the IsMissing function to detect whether or not optional Variant arguments have been provided in calling a procedure. IsMissing returns True if no value has been passed for the specified argument; otherwise, it returns False. If IsMissing returns True for an argument, use of the missing argument in other code may cause a user-defined error. If IsMissing is used on a ParamArray argument, it always returns False. To detect an empty ParamArray, test to see if the array's upper bound is less than its lower bound.

Note:  IsMissing does not work on simple data types (such as Integer or Double) because, unlike Variants, they don't have a provision for a "missing" flag bit. Because of this, the syntax for typed optional arguments allows you to specify a default value. If the argument is omitted when the procedure is called, then the argument will have this default value, as in the example below:

Note: Examples that follow demonstrate the use of this function in a Visual Basic for Applications (VBA) module. For more information about working with VBA, select Developer Reference in the drop-down list next to Search and enter one or more terms in the search box.

Sub MySub(Optional MyVar As String = "specialvalue")
If MyVar = "specialvalue" Then
' MyVar was omitted.
End Sub

In many cases you can omit the If MyVar test entirely by making the default value equal to the value you want MyVar to contain if the user omits it from the function call. This makes your code more concise and efficient.


This example uses the IsMissing function to check if an optional argument has been passed to a user-defined procedure. Note that Optional arguments can now have default values and types other than Variant.

Dim ReturnValue
' The following statements call the user-defined
' function procedure.
ReturnValue = ReturnTwice() ' Returns Null.
ReturnValue = ReturnTwice(2) ' Returns 4.
' Function procedure definition.
Function ReturnTwice(Optional A)
If IsMissing(A) Then
' If argument is missing, return a Null.
ReturnTwice = Null
' If argument is present, return twice the value.
ReturnTwice = A * 2
End If
End Function

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!