another alternative, using your sample file:
Formula:
C1: =MATCH(REPT("Z",255),$A:$A)
then
Formula:
D2: =IFERROR(INDEX($A:$A,AGGREGATE(15,6,ROW($A$2:INDEX($A:$A,$C$1))/ISNA(MATCH($A$2:INDEX($A:$A,$C$1),$D$1:$D1,0)),1)),"")
copied down as far as required
E2: =IF(D2="","",IFERROR(INDEX($B:$B,AGGREGATE(15,6,ROW($B$2:INDEX($B:$B,$C$1))/($A$2:INDEX($A:$A,$C$1)=$D2),COLUMNS($E2:E2))),""))
applied to matrix E2:XY {XY being discretionary -- Y should obviously accommodate max. number of items for single row}
Bookmarks