Sheet1, A:E, houses the data...
[TABLE="width: 240"]
<colgroup><col style="width: 48pt;" span="5" width="64"> <tbody>[TR]
[TD="class: xl63, width: 64, bgcolor: transparent"] [/TD]
[TD="class: xl63, width: 64, bgcolor: transparent"] [/TD]
[TD="class: xl63, width: 64, bgcolor: transparent"] [/TD]
[TD="class: xl63, width: 64, bgcolor: transparent"] [/TD]
[TD="class: xl63, width: 64, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent, align: right"]
201[/TD]
[TD="class: xl63, bgcolor: transparent"]
Black[/TD]
[TD="class: xl63, bgcolor: transparent"]
White[/TD]
[TD="class: xl63, bgcolor: transparent"] [/TD]
[TD="class: xl63, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent, align: right"]
202[/TD]
[TD="class: xl63, bgcolor: transparent"]
Black[/TD]
[TD="class: xl63, bgcolor: transparent"]
Grey[/TD]
[TD="class: xl63, bgcolor: transparent"] [/TD]
[TD="class: xl63, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent, align: right"]
203[/TD]
[TD="class: xl63, bgcolor: transparent"]
White[/TD]
[TD="class: xl63, bgcolor: transparent"]
Grey[/TD]
[TD="class: xl63, bgcolor: transparent"] [/TD]
[TD="class: xl63, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent, align: right"]
401[/TD]
[TD="class: xl63, bgcolor: transparent"]
Black[/TD]
[TD="class: xl63, bgcolor: transparent"]
Grey[/TD]
[TD="class: xl63, bgcolor: transparent"]
Red[/TD]
[TD="class: xl63, bgcolor: transparent"]
Blue[/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent, align: right"]
402[/TD]
[TD="class: xl63, bgcolor: transparent"]
White[/TD]
[TD="class: xl63, bgcolor: transparent"]
Yellow[/TD]
[TD="class: xl63, bgcolor: transparent"]
Blue[/TD]
[TD="class: xl63, bgcolor: transparent"]
Grey[/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent"] [/TD]
[TD="class: xl63, bgcolor: transparent"] [/TD]
[TD="class: xl63, bgcolor: transparent"] [/TD]
[TD="class: xl63, bgcolor: transparent"] [/TD]
[TD="class: xl63, bgcolor: transparent"] [/TD]
[/TR]
</tbody>[/TABLE]
Sheet2, A:B, houses the processing...
[TABLE="width: 201"]
<colgroup><col style="width: 48pt;" width="64"> <col style="width: 153pt; mso-width-source: userset; mso-width-alt: 7253;" width="204"> <tbody>[TR]
[TD="class: xl65, width: 64, bgcolor: transparent"] [/TD]
[TD="class: xl65, width: 204, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: transparent"]
Black[/TD]
[TD="class: xl65, bgcolor: transparent"]
201, 202, 401[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: transparent"]
White[/TD]
[TD="class: xl65, bgcolor: transparent"]
201, 203, 402[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: transparent"]
Grey[/TD]
[TD="class: xl65, bgcolor: transparent"]
202, 203, 401, 402[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: transparent"]
Red[/TD]
[TD="class: xl65, bgcolor: transparent"]
401[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: transparent"]
Blue[/TD]
[TD="class: xl65, bgcolor: transparent"]
401, 402[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: transparent"]
Yellow[/TD]
[TD="class: xl65, bgcolor: transparent"]
402[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: transparent"] [/TD]
[TD="class: xl65, bgcolor: transparent"] [/TD]
[/TR]
</tbody>[/TABLE]
First, add the following code as a module to your workbook using Alt+F11...
Function aconcat(a As Variant, Optional sep As String = "") As String
' Harlan Grove, Mar 2002
Dim y As Variant
If TypeOf a Is Range Then
For Each y In a.Cells
aconcat = aconcat & y.Value & sep
Next y
ElseIf IsArray(a) Then
For Each y In a
aconcat = aconcat & y & sep
Next y
Else
aconcat = aconcat & a & sep
End If
aconcat = Left(aconcat, Len(aconcat) - Len(sep))
End Function
Now invoke on Sheet2...
B2, control+shift+enter, not just enter, and copy down:
Rich (BB code):
=REPLACE(aconcat(IF(FREQUENCY(IF(Sheet1!$A$2:$A$6<>"",
IF(Sheet1!$B$2:$E$6=$A2,MATCH(Sheet1!$A$2:$A$6,Sheet1!$A$2:$A$6,0))),
ROW(Sheet1!$A$2:$A$6)-ROW(Sheet1!$A$2)+1),", "&Sheet1!$A$2:$A$6,"")),1,2,"")