Posts by TonyTuperello

    The scripting dictionary will not allow you to add a duplicate key. As such, it must check to make sure the key already exists when you add it. Your code forces it to check twice. The way to avoid this is to turn off error trapping for just long enough to add the keys. Duplicates will still not be added.

    On Error Resume Next
    For i = 1 To UBound(v1, 1)
    rngList.Add Key:=Val, Item:=i + 1
    Next i
    On Error Goto 0 'Turns error catch back on

    This should speed your code up by a fair amount if you are processing long lists.

    I am not sure if this is your intention. As you have not uploaded a sample, I don't know what you are processing.

    But, you are saving the value from the array as the key and making the item value of the dictionary the index of the array (+1?!?!) (which will not be sequential if there are duplicates!) This may be by design, but I don't see it.

    Consider making the key and and the item the same for purely esthetic purposes. Is there a reason to save the value of i?