Batman,
Yes, you were correct. You seem to have a very good handle on dictionary. Perhaps you can explain why this code errors:
Code:
Sub Test()
Dim oDic As Object, oKey
Dim varVals
Dim lngIndex As Long
varVals = Split("APPLES,Apples,Pears,Pears,PEARS,pears,Blueberries,APPLES", ",")
Set oDic = CreateObject("Scripting.Dictionary")
oDic.CompareMode = 1
For lngIndex = 0 To UBound(varVals)
If oDic.Exists(varVals(lngIndex)) Then
oDic.Item(varVals(lngIndex)) = oDic.Item(varVals(lngIndex)) + 1
Else
oDic.Add varVals(lngIndex), 1
End If
Next
For Each oKey In oDic.Keys
MsgBox oKey & " count = " & oDic.Item(oKey)
Next oKey
'Why can't set oKey to a spefic key index e.g.:
oKey = oDic.Keys(1).Value 'Errors here
MsgBox oKey & " count = " & oDic.Item(oKey)
lbl_Exit:
Exit Sub
End Sub
Looking at the Debugger Watches windows, oDic.Keys(1) definitely has a value.