Concatenate Two Data sets with and Without Dupes

     

  • Click on image to watch video
  •  

     

     

    Sub WithoutDupes()
    r = 2
    Do Until Range("A" & r).Value = ""
    Range("D" & r).ClearContents
    For C = 1 To 2
    DataSet = Split(Cells(r, C).Value, ",")
    For D = 0 To UBound(DataSet)
    If C = 1 And Range("D" & r).Value = "" Then
    Range("D" & r).Value = DataSet(0) & ","
    Else:
    resultset = Split(Range("D" & r).Value, ",")
    DataExists = ""
    For Z = 0 To UBound(resultset)
    If DataSet(D) = resultset(Z) Then
    DataExists = "Yes"
    Exit For
    End If
    Next
    If DataExists <> "Yes" Then
    Range("D" & r).Value = Range("D" & r).Value + DataSet(D) & ","
    DataExists = ""
    End If
    End If
    Next
    Next
    Range("D" & r).Value = Left(Range("D" & r).Value, Len(Range("D" & r).Value) - 1)
    r = r + 1
    Loop
    End Sub


    Sub WithDupes()
    r = 2
    Do Until Range("A" & r).Value = ""
    Range("C" & r).ClearContents
    Range("C" & r).Value = Range("A" & r).Value & "," & Range("B" & r).Value
    r = r + 1
    Loop
    End Sub

     

    Download The Workbook