My approach is a little bit different, but at least it doesn't limited to only CW, CF and MC.
Sub Consolidate()
Dim MyCollection As Collection
Dim ws As Worksheet
Dim LR As Long, i As Long, j As Long
Dim LR_Cust As Long
Dim strCustomer As String
Set MyCollection = New Collection
Set ws = ActiveSheet
With ws
LR = .Cells(Rows.Count, 1).End(xlUp).Row
.Columns("I:M").Delete
.Range("A1:B" & LR & ",D1:E" & LR).Copy .Cells(1, 9)
.Cells(1, 9).CurrentRegion.RemoveDuplicates Columns:=1, Header:=xlYes
.Columns("K").Insert
.Cells(1, "K").Value = "Program"
LR_Cust = .Cells(Rows.Count, 9).End(xlUp).Row
For i = 2 To LR_Cust
For j = 2 To LR
If .Cells(j, 2).Value = .Cells(i, 10).Value Then
strCustomer = strCustomer & "," & .Cells(j, 3).Value
End If
Next j
strCustomer = Right(strCustomer, Len(strCustomer) - 1)
MyCollection.Add strCustomer, .Cells(i, 10)
strCustomer = ""
Next i
For i = 2 To LR_Cust
.Cells(i, "K").Value = MyCollection.Item(.Cells(i, "J").Value)
Next i
End With
End Sub
Bookmarks