D2:G12{=IFERROR(INDEX($C:$C,SMALL(IF($C2=$B$15:$B$23,ROW($15:$23)),COLUMN(A1))),IF(B$1=$B$1,C2,""))
L2{=IFERROR(INDEX(B:B,RIGHT(SMALL(IF(D$2:G$12<>"",MATCH(B$2:B$12,B:B,)/1%+ROW($2:$12)),ROW(A1)),2)),"")
M2{=INDIRECT(TEXT(SMALL(IF((D$2:G$12<>"")*(B$2:B$12=L2),ROW($2:$12)/1%+{4,5,6,7},9999),COUNTIF(L$2:L2,L2)),"!R0C00"),)&""
I2{=IFERROR(INDEX(B:B,RIGHT(SMALL(IF(TEXT(COUNTIF(B$15:B$23,C$2:C$12),"0;;1")-{1,2,3,4,5}>=0,ROW($2:$12)+MATCH(B$2:B$12,B:B,)/1%),ROW(A1)),2)),"")
J2{=INDEX(C:C,SMALL(TEXT((B$2:B$12=I2)*IF(COUNTIF(B$15:B$23,C$2:C$12),(C$2:C$12=TRANSPOSE(B$15:B$23))*COLUMN(O:W),ROW($2:$12)*(COLUMN(O:W)=15)),"0;;99")*1,COUNTIF(I$2:I2,I2)))&"" |