Select Case not working

SandsB

Well-known Member
Joined
Feb 13, 2007
Messages
681
Office Version
  1. 365
Platform
  1. Windows
This worked for me until I tried to add a second region. It seems to just ignore the second check. What's not right here?
----

Dim intResp As Integer
'East Region check
Select Case UCase(Range("$D$9"))
Case "East"
Select Case UCase(Range("$D$46"))
Case Is = "AL", "FL", "GA", "MS", "NC"
Case Else
intResp = MsgBox("There's a mismatch. Click Cancel to correct or OR to continue.", vbOKCancel, "State / Region Mismatch")
Select Case intResp
Case Is = vbCancel 'or 2
Exit Sub
Case Else 'or = vbOK or 1
End Select
End Select

'West Region check
Select Case UCase(Range("$D$9"))
Case "West"
Select Case UCase(Range("$D$46"))
Case Is = "CA", "OR"
Case Else
intResp = MsgBox("There's a mismatch. Click Cancel to correct or OR to continue.", vbOKCancel, "State / Region Mismatch")
Select Case intResp
Case Is = vbCancel 'or 2
Exit Sub
Case Else 'or = vbOK or 1
End Select
End Select
End Select
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
UCase(Range("$D$9")) will never be "East".

Try

Code:
Select Case Range("$D$9").Value
    Case "East"

Similarly with the West check.
 
Upvote 0
SandsB

Please continue in the original thread.:)

You don't need all those Select...Case structures and I'm afraid the code is pretty hard follow without indentation.

Or an explanation of it's purpose or the logic.:)
 
Upvote 0

Forum statistics

Threads
1,203,263
Messages
6,054,434
Members
444,725
Latest member
madhink

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top