Non Case Sensitive Dictionary

DataBlake

Well-known Member
Joined
Jan 26, 2015
Messages
781
Office Version
  1. 2016
Platform
  1. Windows
So i have a dictionary of colors
some vendors like to write in all caps, some like to write in proper, some like to write in lowercase, some have their own thing goin on?
anyways my statement here

Code:
ary2(i, 4) = dicFINISH.Item(ary2(i, 4))

takes their color description and replaces it with a shortened version
"Silver Trimmed Blue"
but another person writes it as "SILVER TRIMMED BLUE"
is there a way i can do this where case sensitivity does not matter?
 

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).
Not sure if there is a way to ignore case but you could change both parts to lower case to make them equal.

Code:
LCase(ary2(i, 4)) = LCase(dicFINISH.Item(ary2(i, 4)))
 
Upvote 0
Not sure if there is a way to ignore case but you could change both parts to lower case to make them equal.

Code:
LCase(ary2(i, 4)) = LCase(dicFINISH.Item(ary2(i, 4)))

i don't know that this works with a dictionary object
i get "424 - object required" when i try to change the dictionary item to lowercase
when all else fails i can change all of the dictionary items themselves to lowercase, but if there is another method i would prefer that.
 
Upvote 0
Set the Dictionary's CompareMode property to vbtextcompare.
 
Upvote 0
Set the Dictionary's CompareMode property to vbtextcompare.

i must be doing this incorrectly ?

Code:
dicFINISH.comparemode = TextCompare
ary2(i, 4) = dicFINISH.Item(ary2(i, 4))
 
Upvote 0
or does this declaration need to be made before the entries are added to the dictionary?
 
Upvote 0
It should be:
Code:
dicFINISH.comparemode = vbTextCompare

or does this declaration need to be made before the entries are added to the dictionary?
Yes
 
Upvote 0
Yes before you populate it, and it’s vbtextcompare not just textcompare
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

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