VBA CASE with additional condition

I need another condition in this code.
IF Q = "US" and AG <> "US" then the code below.

IF Q <> "US" and AG = "US" then a variation on the code below.
    Case "A"
        vBD(i, 1) = 2
    Case "C"
        vBD(i, 1) = 3
    Case "D"
        vBD(i, 1) = 4
    Case "E"
        vBD(i, 1) = 5
    Case "F"
        vBD(i, 1) = 6
    Case "G"
        vBD(i, 1) = 7
    Case "H"
        vBD(i, 1) = 8
    Case "I"
        vBD(i, 1) = 9
    Case "J"
        vBD(i, 1) = 10
    Case "K"
        vBD(i, 1) = 11
    Case "L"
        vBD(i, 1) = 12
    Case "M"
        vBD(i, 1) = 13
    Case "N"
        vBD(i, 1) = 14
    Case "O"
        vBD(i, 1) = 15
    Case "P"
        vBD(i, 1) = 16


    Case "IE", "IP", "IPF", "IEF"
    Select Case vBD(i, 1)
    Case "A"
        vBD(i, 1) = 2
    Case "B"
        vBD(i, 1) = 3
    Case "C"
        vBD(i, 1) = 4
    Case "D"
        vBD(i, 1) = 5
    Case "E"
        vBD(i, 1) = 6
    Case "F"
        vBD(i, 1) = 7
    Case "G"
        vBD(i, 1) = 8
    Case "H"
        vBD(i, 1) = 9
    Case "I"
        vBD(i, 1) = 10
    Case "J"
        vBD(i, 1) = 11
    Case "K"
        vBD(i, 1) = 12
    Case "L"
        vBD(i, 1) = 13
    Case "M"
        vBD(i, 1) = 14
    Case "N"
        vBD(i, 1) = 15
    Case "O"
        vBD(i, 1) = 16

    End Select

Open in new window

Euro5Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Is the wished result indeed nothing else than to set the same var to the values 2 to 16, according to the letter positiion in the alphabet? That can be achieved more simple.

Your conditions are not totally clear. E.g. the opposite of  Q = "US" and AG <> "US" is Q <> "US" or AG = "US". We cannot see which code should be executed in which case either.

Please try to rephrase your question.
Martin LissOlder than dirtCommented:
And a sample workbook would help.
Euro5Author Commented:
This is the complete file. The sub is Sub Zone_Change()


I need to distinguish between Inbound/Export using Q & AG.
I also need to eliminate the possible non Import/Export (to/from other countries), so I need to use both Q & AG.

If Q= "US" and AG <> "US" then I need
Case "A" = 2
Case "B" = 3
Case "C" = 4
Case "D" = 5
Case "E" = 6
Case "F" = 7
Case "G" = 8
Case "H" =  9
Case "I" = 10
Case "J" = 11
Case "K" = 12
Case "L" = 13
Case "M" = 14
Case "N" = 15
Case "O" = 16
Case "P" = 17

BUT
If Q<> "US" and AG = "US" then I need

Case "A" = 2
Case "C" = 3
Case "D" = 4
Case "E" = 5
Case "F" = 6
Case "G" = 7
Case "H" =  8
Case "I" = 9
Case "J" = 10
Case "K" = 11
Case "L" = 12
Case "M" = 13
Case "N" = 14
Case "O" = 15
Case "P" = 16
What-if-scenario-v2.xlsm
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

Martin LissOlder than dirtCommented:
Qlemo is right when he says  this (at least the first part) can be done more simply, but I didn't do that because of the missing case "B" in the second part.
    Case "IE", "IP", "IPF", "IEF"
    If .Cells(i, "Q") = "US" And .Cells(i, "AG") <> "US" Then
        Select Case vBD(i, 1)
        Case "A"
            vBD(i, 1) = 2
        Case "B"
            vBD(i, 1) = 3
        Case "C"
            vBD(i, 1) = 4
        Case "D"
            vBD(i, 1) = 5
        Case "E"
            vBD(i, 1) = 6
        Case "F"
            vBD(i, 1) = 7
        Case "G"
            vBD(i, 1) = 8
        Case "H"
            vBD(i, 1) = 9
        Case "I"
            vBD(i, 1) = 10
        Case "J"
            vBD(i, 1) = 11
        Case "K"
            vBD(i, 1) = 12
        Case "L"
            vBD(i, 1) = 13
        Case "M"
            vBD(i, 1) = 14
        Case "N"
            vBD(i, 1) = 15
        Case "O"
            vBD(i, 1) = 16
        End Select
    ElseIf .Cells(i, "Q") <> "US" And .Cells(i, "AG") = "US" Then
        Select Case vBD(i, 1)
        Case "A"
            vBD(i, 1) = 2
        Case "C"
            vBD(i, 1) = 3
        Case "D"
            vBD(i, 1) = 4
        Case "E"
            vBD(i, 1) = 5
        Case "F"
            vBD(i, 1) = 6
        Case "G"
            vBD(i, 1) = 7
        Case "H"
            vBD(i, 1) = 8
        Case "I"
            vBD(i, 1) = 9
        Case "J"
            vBD(i, 1) = 10
        Case "K"
            vBD(i, 1) = 11
        Case "L"
            vBD(i, 1) = 12
        Case "M"
            vBD(i, 1) = 13
        Case "N"
            vBD(i, 1) = 14
        Case "O"
            vBD(i, 1) = 15
        End Select
   End Select

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Sounds reasonable, as long as you do not care about non-US to non-US, which is very likely.
Euro5Author Commented:
@Olemo, right, they are just removed.
Martin LissOlder than dirtCommented:
Thank you for my three millionth point!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.