CHECK if value is in ????

User avatar
sal21
PlatinumLounger
Posts: 4368
Joined: 26 Apr 2010, 17:36

CHECK if value is in ????

Post by sal21 »

Instead to use multiple if...end to intercept a value for condition is possible to check if value is present in a strng array???

example:

if AA
is this array (AA,AB, AC,......ZZ)
then

i hope you understabd me:-)

User avatar
HansV
Administrator
Posts: 78615
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: CHECK if value is in ????

Post by HansV »

You could use

Code: Select all

Dim MyVar As String
MyVar = ...
Select Case MyVar
    Case "AA", "AB", "AC", "ZZ"
        ' Do something
    Case Else
        ' Do something else
End Select
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4368
Joined: 26 Apr 2010, 17:36

Re: CHECK if value is in ????

Post by sal21 »

HansV wrote:You could use

Code: Select all

Dim MyVar As String
MyVar = ...
Select Case MyVar
    Case "AA", "AB", "AC", "ZZ"
        ' Do something
    Case Else
        ' Do something else
End Select
:fanfare: :fanfare: :fanfare: :clapping: :clapping: :clapping: :clapping: