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?

Deduplicator
  • 43,322
  • 6
  • 62
  • 109
Alex Gordon
  • 54,010
  • 276
  • 644
  • 1,024

1 Answers1

1

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
  • 2,885
  • 1
  • 16
  • 14
  • 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 – Alex Gordon Jun 11 '10 at 16:49
  • 1
    You missing out `On Error Resume Next` which omits your error and keeps going, thus your unique values. – Mike Jun 11 '10 at 16:51