You'll need to extract unique values and then concatenate those values.
When a2:a7 = {a, a, b, b, b, c}
, type this at b2
and hit ctrl + shift + enter
.
=IFERROR(INDEX($A$2:$A$7,MATCH(SUM(COUNTIF(B$1:B1,$A$2:$A$7)),COUNTIF($A$2:$A$7,"<"&$A$2:$A$7),0)),"")
Then copy b2
and paste it onto b3:b7
. Now you have a list of unique values. This method is from this answer.
Now that you have the list, you only have to join them. type this at c2
.
=IF(B2="", "", B2&";"&CHAR(10))
&IF(B3="", "", B3&";"&CHAR(10))
&IF(B4="", "", B4&";"&CHAR(10))
&IF(B5="", "", B5&";"&CHAR(10))
&IF(B6="", "", B6&";"&CHAR(10))
&IF(B7="", "", B7&";"&CHAR(10))
See the picture.
I know this is ulgy. But there's no built-in formula in Excel. Other workarounds without VBA are here and there, just in case.
By the way, Google Spreadsheet provides all of these as built-in functions. Just one line.
=join(";"&char(10), filter(unique(A2:A7), not(isblank(unique(A2:A7)))))&";"