Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
949 views
in Technique[技术] by (71.8m points)

concatenation - How can I concatenate multiple cells from the same column and different lines in Excel?

I have 3 columns of data and need to concatenate two values of the same column, but are grouped by a separate column (Column A). In this example below, I need to combine the Brand + Product Type (column C) for a total of 66 concatenated values.

How can I get the concatenated values I need? There's thousands that I need to combine.

ABC Diffusers
ABC Hot & Cold Therapy
ABC Humidifiers
DEF Oils
DEF Diffusers
DEF Candles
DEF Air Fresheners
etc.

Values

question from:https://stackoverflow.com/questions/65864021/how-can-i-concatenate-multiple-cells-from-the-same-column-and-different-lines-in

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This solution works for versions of Excel that support LET and dynamic arrays

I cut you data down a little to save space but this should give you an idea.

Sample solution

The yellow cells have formulas, the rest is spilled dynamic arrays.

G2 lists the unique titles horizontally. =TRANSPOSE(UNIQUE(A3:A12))

G3 lists all of the diffuser combos.

=LET(titleList,$A$3:$A$12,
     groupList,$B$3:$B$12,
     nameList,$C$3:$C$12,
     Title,G2,
     brandList,TRANSPOSE(FILTER(nameList,(titleList=Title)*(groupList="Brand"))),
     productType,FILTER(nameList,(titleList=Title)*(groupList="Product Type")),
     combos,brandList&" "&productType,
     numRows,ROWS(combos),
     numCols,COLUMNS(combos),
     outRows,SEQUENCE(numRows*numCols),
     
     INDEX(combos,MOD(outRows-1,numRows)+1,INT((outRows-1)/numRows)))

H3 lists all of essential-oils combos. It is G3 copied. A1 shows the max length of the combos for each Title. =MAX(COUNTIFS($A$3:$A$12,G2#,$B$3:$B$12,"Brand")*COUNTIFS($A$3:$A$12,G2#,$B$3:$B$12,"Product Type"))

E3 lists all of the unique combos.

=LET(numRows,A1,
     numCols,COLUMNS(G2#),
     data,OFFSET(G3,0,0,numRows,numCols),
     outRows,SEQUENCE(numRows*numCols),
     oneCol,INDEX(data,MOD(outRows-1,numRows)+1,INT((outRows-1)/numRows)+1),

     FILTER(oneCol,oneCol<>0))

More info on LET More info on dynamic arrays


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...