Random dictionary

I installed the dictionary as an object, adding a few elements to this dictionary, however, it seems to be case sensitive. In any case, can I install a dictionary for recognizing different versions?

My code is:

Sub Test()

Dim sheet1 As String
Dim Dict As Object
Dim c As Range

Sheet1= "TEST"
Set Dict = CreateObject("Scripting.Dictionary")

Dict.Add "MIKE", 0
Dict.Add "PHIL", 0
Dict.Add "Joe", 0

For Each c In ActiveWorkbook.Worksheets(Sheet1).UsedRange
If Dict.Exists(ActiveWorkbook.Worksheets(Sheet1).Cells(c.Row, c.Column).Value) Then
        Dict(ActiveWorkbook.Worksheets(Sheet1).Cells(c.Row, c.Column).Value) = Dict(ActiveWorkbook.Worksheets(Sheet1).Cells(c.Row, c.Column).Value) + 1
End If
Next

Sheet1.Cells(25, 3) = Dict("MIKE")
Sheet1.Cells(25, 3) = Dict("PHIL")
Sheet1.Cells(25, 3) = Dict("Joe")

Set Dict = Nothing

End Sub

So, I want to recognize "mike" for MIKE and "Phil" for PHIL, etc.

Thanks in advance!

+4
source share
2 answers

Adding on @Ralph

dict.CompareMode = TextCompare

I changed the file to.

0
source

I always like to ask everything for my coding. Thus, all modules and code that are on my sheets or in forms begin with the following three lines before writing any additional code.

Option Base 0
Option Explicit
Option Compare Text

- - - Sub, Sub , ():

dict.CompareMode = BinaryCompare 'if I need a case-sensitive compare in this sub
+4

Source: https://habr.com/ru/post/1599468/


All Articles