View Full Version : Solved: If Statement Insanity

12-26-2012, 01:41 PM
What is wrong with this IF statement?

If Not ((UCase(countryRange.Value) = "US") Or (UCase(countryRange.Value) = "PR") Or (UCase(countryRange.Value) = "VI") Or (UCase(countryRange.Value) = "GU")) Then ' if not US or PR or GU or VI
Debug.Print countryRange.Value

This is getting a lot of rows returning saying "US" even though the IF statement explicitly catches the US country code..What am I doing wrong?

12-26-2012, 02:19 PM
Nevermind, i forgot to Trim the variable i was checking...

12-27-2012, 08:46 AM
This syntax might be more readable

Select Case UCase(countryRange.Value))
Case "US", "PR", "VI", "GU"
' do nothing
Case Else
Debug.Print countryRange.Value
End Select