VBA Multiple If Comparison (1 Viewer)

vgarzon

Registered User.
Local time
Today, 07:04
Joined
Oct 17, 2008
Messages
30
Hi All,

What I'm about to ask may seem pretty basic, although I Haven't fount it's answer yet....

What I need to do is to evaluate a condition like:

Code:
If (PL = "X" or PL = "YT" or PL = "PG" or PL = "WL" or PL = "ZO" or PL = "QL")

Actually, is like that but with 22 "ORs". It works but it I think it's the ugly way of doing it. I was wondering if any of you know how to do it like you do that in SQL, like usin a sentence like :

Code:
PL IN ("X", "YT", "PG", "WL", "ZO", "QL)

I hope you can help me with this issue.

Thanks in advance,
Victor
 

Brianwarnock

Retired
Local time
Today, 13:04
Joined
Jun 2, 2003
Messages
12,701
How about a Select Case?

Select Case PL
Case "X", "YT", "PG", "WL", "ZO", "QL
etc


Brian
 

datAdrenaline

AWF VIP
Local time
Today, 07:04
Joined
Jun 23, 2008
Messages
697
Another method for consideration is the InStr() function ...

If InStr(1,"|X|YT|PG|WL|ZO|QL|","|" & PL & "|") > 0 Then ...
 

Users who are viewing this thread

Top Bottom