tags:

views:

167

answers:

1
Dim arr As New Collection, a
Dim aFirstArray() As Variant    

...some code

For Each a In aFirstArray
   arr.Add a, a
Next

i get this error: This key is already associated with an element of this collection

on this line : arr.Add a, a

what am i doing wrong?

+1  A: 

Some more code?

from this what you have all I can tell you is that what your error says. The a is already in the collection (the key is supposed to be an unique string). BTW. is the a a string?

Or maybe you have some repetition in your array which would try to add 1+ time the same item?

Mike
mike im using this code: http://stackoverflow.com/questions/3017852/vba-get-unique-values-from-array/3017973#3017973 to get unique values from the array
I__
yes its a string
I__
You missing out `On Error Resume Next` which omits your error and keeps going, thus your unique values.
Mike
thank you!!!!!!!!!!!!!
I__