How do I test if optional arguments are supplied or not? -- in VB6 / VBA
Function func (Optional ByRef arg As Variant = Nothing)
If arg Is Nothing Then
Most of these refer to the variant type, or test if a value is blank.
However, sometimes you want to check if a range, workbook, worksheet, or other type of object is not passed, without checking things like sheetnames.
In that case:
DesiredRange is Nothing
Returns a boolean. For example:
If DestinationRange Is Nothing Then
MsgBox "Need a destination range when importing data"
Else
'We're happy
End If