Consulting

Results 1 to 2 of 2

Thread: Remove duplicated values from 1d string array vba

  1. #1

    Remove duplicated values from 1d string array vba

    Hi there,
    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. I am new to arrays BTW.
    I have tried to use Collections but I keep getting a type mismatch error.
    Thanks a lot.
    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

  2. #2
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Try
    If Cells(i, 2).Interior.ColorIndex = 43 Then 
        Filename = Path + Sheet1.Cells(i, 1)
        If IsError(Application.Match(FileName, FileNames, 0) Then
            x = x + 1 
            Filenames(x) = Filename 
        End If
    End If

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •