=LEFT(CONCAT(IFERROR(IF(IFERROR(IF(MATCH(IF($B$2:$B$13=B2,$A$2:$A$13,""),A:A,)=ROW($2:$13),ROW($2:$13),""),"")=MIN(IFERROR(IF(MATCH(IF($B$2:$B$13=B2,$A$2:$A$13,""),A:A,)=ROW($2:$13),ROW($2:$13),""),"")),INDEX(A:A,IFERROR(IF(MATCH(IF($B$2:$B$13=B2,$A$2:$A$13,""),A:A,)=ROW($2:$13),ROW($2:$13),""),"")),LEFT(INDEX(A:A,IFERROR(IF(MATCH(IF($B$2:$B$13=B2,$A$2:$A$13,""),A:A,)=ROW($2:$13),ROW($2:$13),""),"")),3)&RIGHT(INDEX(A:A,IFERROR(IF(MATCH(IF($B$2:$B$13=B2,$A$2:$A$13,""),A:A,)=ROW($2:$13),ROW($2:$13),""),"")),3))&"丨","")),LEN(CONCAT(IFERROR(IF(IFERROR(IF(MATCH(IF($B$2:$B$13=B2,$A$2:$A$13,""),A:A,)=ROW($2:$13),ROW($2:$13),""),"")=MIN(IFERROR(IF(MATCH(IF($B$2:$B$13=B2,$A$2:$A$13,""),A:A,)=ROW($2:$13),ROW($2:$13),""),"")),INDEX(A:A,IFERROR(IF(MATCH(IF($B$2:$B$13=B2,$A$2:$A$13,""),A:A,)=ROW($2:$13),ROW($2:$13),""),"")),LEFT(INDEX(A:A,IFERROR(IF(MATCH(IF($B$2:$B$13=B2,$A$2:$A$13,""),A:A,)=ROW($2:$13),ROW($2:$13),""),"")),3)&RIGHT(INDEX(A:A,IFERROR(IF(MATCH(IF($B$2:$B$13=B2,$A$2:$A$13,""),A:A,)=ROW($2:$13),ROW($2:$13),""),"")),3))&"丨","")))-1)
|