scripting.dictionary doesn't recognise numbers

got this code:

Dim a, i As Long
With Range("K1", Range("K" & Rows.Count).End(xlUp))
    a = .Value
End With
With CreateObject("Scripting.Dictionary")
    .CompareMode = vbTextCompare
    .Add "test", 1
    For i = 1 To UBound(a, 1)
        If .exists(a(i, 1)) Then
            Cells(i, 14).Value = 1
            Cells(i, 14).Value = 0
        End If
End With

It perfectly will give me a "1" in column 14 when the word "test" is anywhere in column K.

If I change the ".Add "test", 1" line to ".Add "21", 1" it only returns "0" although I have "21" in column K.

On the net is says that .key values can be any value(text, numbers, etc). As column K only contains numbers(1 to 25) I need the script to mark occurrences of 1 of those numbers and I really want to use "scripting.dictionary" as it is the fastest way.

What am I doing wrong or doesn't "scripting.dictionary" support numbers only.


Solved it. Needed to change the line to:

.Add 21, 1

So 21 without the quotes.

Need Your Help

Adding soap headers in apache camel

wso2 soapheader

I am calling a soap web service from Apache Camel, which is having header (for authentication) and the body. My Dataformat is POJO (tried with PAYLOAD too) Nothing got succeeded.