0

I am trying to find a way to remove duplicated values in an array. This is the code I have so far which populates the array with no problem.

Dim Filename As String
Dim Filenames(0 To 100) As String
Dim i, x As Integer
Dim Path As String

For i = 2 To 10
        If Cells(i, 2).Interior.ColorIndex = 43 Then
        Filename = Path + Sheet1.Cells(i, 1)
        x = x + 1
        Filenames(x) = Filename
        End If
Next i
  • You should've checked those: [https://stackoverflow.com/questions/38267950/check-if-a-value-is-in-an-array-or-not-with-excel-vba](https://stackoverflow.com/questions/38267950/check-if-a-value-is-in-an-array-or-not-with-excel-vba) [https://stackoverflow.com/questions/14205999/vba-arrays-check-strict-not-approximative-match](https://stackoverflow.com/questions/14205999/vba-arrays-check-strict-not-approximative-match) – Zhurik Oct 15 '17 at 18:10
  • Add the items to a collection specifying the second Key argument when adding items. Or use a dictionary. See here: https://stackoverflow.com/questions/3017852/vba-get-unique-values-from-array – QHarr Oct 15 '17 at 18:18
  • I am getting type mismatch error when I tried a value as collection. I changed the variables Filenames as New collection, a and Filename as variant. – Lisa Betancourt Oct 15 '17 at 18:47

0 Answers0