Search code examples
excelexcel-formulaconcatenation

Excel New Column Distinct Cells


STUDENT 1 2 3 4 5 6 7
A cat, dog
B cat dog
C fox, fox
D fox, fox fox dog

This is my data and for each STUDENT (A, B, C, D) I wish to create in the new column WANT the sequence of ALL entries, so end up with this:

STUDENT 1 2 3 4 5 6 7 WANT
A cat, dog cat, dog
B cat dog cat; dog
C fox, fox fox, fox
D fox, fox fox dog fox, fox; fox; dog

I tried J2: =UNIQUE(B2:H2) with no successes


Solution

  • As it was suggested in the comment section of the question:

    =BYROW(B2:H5, LAMBDA(x, TEXTJOIN("; ",,x)))
    

    Here is the output: output

    Note: Remember, if the resulting string exceeds 32767 characters (cell limit), TEXTJOIN returns the #VALUE! error.