IsMissing function is to check whether Option Variant has been past through from procedure to called procedure or not. The return value is Boolean either True or False. If really missing then True else False.
Syntax : IsMissing(Variables) , Return True/False
1) Below example Main procedure Called Sub procedure but did not assigned StrVar.
VBA Vode:
Option Explicit
Sub Examples_IsMissingCalling_True()
Examples_IsMissingCalled 'Cause IsMissing is True
End Sub
Public Sub Examples_IsMissingCalled(Optional ByVal StrVar As Variant)
Debug.Print IsMissing(StrVar) 'Result is True
End Sub
Sub Examples_IsMissingCalling_True()
Examples_IsMissingCalled 'Cause IsMissing is True
End Sub
Public Sub Examples_IsMissingCalled(Optional ByVal StrVar As Variant)
Debug.Print IsMissing(StrVar) 'Result is True
End Sub
Note: The above case StrVar is Missing then result is True.
2) Below example Main procedure Called Sub procedure but assigned StrVar = StrVarA.
VBA Vode:
Option Explicit
Sub Examples_IsMissingCalling_False()
Dim StrVarA As Variant
Examples_IsMissingCalled StrVar:=StrVarA
End Sub
Public Sub Examples_IsMissingCalled(Optional ByVal StrVar As Variant)
Debug.Print IsMissing(StrVar) 'Result is False
End Sub
Sub Examples_IsMissingCalling_False()
Dim StrVarA As Variant
Examples_IsMissingCalled StrVar:=StrVarA
End Sub
Public Sub Examples_IsMissingCalled(Optional ByVal StrVar As Variant)
Debug.Print IsMissing(StrVar) 'Result is False
End Sub
Note: The above case StrVar is Not Missing then result is False.
Other Reference-Ismissing-function
Practice makes perfect. Thank You.
excelmacros
macro excel
excel programming
excel vba
No comments:
Post a Comment