我已将Dictionary设置为对象,并向该字典添加了多个项目,但是它似乎区分大小写。无论如何,我可以设置字典来识别不同的版本吗?
我的代码:
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
因此,我想将MIKE识别为“ mike”,将PHIL等识别为“ Phil”。
提前致谢!
添加到@Ralph
dict.CompareMode = TextCompare
是我将文件更改为的内容。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句