Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In Statement in VBA

Status
Not open for further replies.

ddevil

Technical User
Feb 14, 2006
49
US
When writing a query, I can use an in statement to check for many conditions of a variable, such as Not In ("96833","3228256"). Can I do the same thing in VBA with an if statement or something else?

Such as:
Public Function CheckProject() As String
If (ProjectID not in "011082", "011100","011105","011110", "011118","011123") Then
ProjectID = ""
Else
ProjectID = ProjectID
End If

End Function

This syntax doesn't work, any help would be appreciated. Thank you!
 
Use the Select Case instruction:
Public Function CheckProject() As String
Select Case ProjectID
Case "011082", "011100", "011105", "011110", "011118", "011123"
ProjectID = ProjectID
Case Else
ProjectID = ""
End Select
End Function

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you so much, I knew there had a be a way!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top