Skip to content

Instantly share code, notes, and snippets.

@bervukas
Last active February 28, 2016 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bervukas/6952d2013c40f6a3272f to your computer and use it in GitHub Desktop.
Save bervukas/6952d2013c40f6a3272f to your computer and use it in GitHub Desktop.
Example: Data validation in VBA
Function Test(L1 As Long, L2 As Long, Optional P1 As Variant, Optional P2 As Variant) As String
Dim S As String
If IsMissing(P1) = True Then
S = "P1 Is Missing."
Else
S = "P1 Is Present (P1 = " & CStr(P1) & ")"
End If
If IsMissing(P2) = True Then
S = S & " " & "P2 Is Missing"
Else
S = S & " " & "P2 Is Present (P2 = " & CStr(P2) & ")"
End If
Test = S
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment