[VBA] Ignore Upper and Lower Case letter

Alexlin

New Member
Joined
Sep 29, 2018
Messages
15
Hi Guys, thanks for reading my post. I've encounter another VBA problem again.
The situation is I needa check if the country provided is within my own country list. So I've written below:-

Function BSD(Place As String) As String

Select Case Place
Case "China", "Cyprus", "Czech Republic", "Denmark", "Hungary", "Iceland", "India", "Indonesia", "Ireland", "Israel", "Italy", "Jamaica", ", "Norway", "Pakistan", "Philippine"
BSD = "True"
Case Else
BSD = "False"

End Select

End Function


However, for example, if the country is "CHINA", "ChInA", "chINA", or other combinations, the code that I wrote above could not match my list. Is there any way to solve this problem?? How to modify my code?

Thanks in advance for your help! Have a nice day!
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Use UCase or LCase so

Code:
Select Case UCase(Place)

then

Code:
Case "CHINA"

etc.
 
Upvote 0
Use UCase or LCase so

Code:
Select Case UCase(Place)

then

Code:
Case "CHINA"

etc.

Thanks Steve! It works.
Just dun understand how come it works.
Simply use Ucase an change all the case to capital letter, so it could match ignore the case sensitive.
 
Upvote 0
Don't need to change the code itself
simply add the line at the beginning

Code:
[color=red]Option Compare Text[/color]
Function BSD(Place As String) As String

Select Case Place
Case Is = "China", "Cyprus", "Czech Republic", "Denmark", "Hungary", "Iceland", "India", "Indonesia", "Ireland", "Israel", "Italy", "Jamaica", "Norway", "Pakistan", "Philippine"
BSD = "True"
Case Else
BSD = "False"

End Select

End Function
 
Upvote 0

Forum statistics

Threads
1,216,100
Messages
6,128,824
Members
449,470
Latest member
Subhash Chand

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