简体   繁体   中英

Excel formula for merging rows

Consider the following four rows in a spreadsheet

AAA  VALUE   TAG
AAA  VALUE   TAG2
AAA  VALUE   TAG3
AAA  VALUE   TAG4

I want to be able to combine all four of these rows into a single row as follows:

AAA  VALUE    TAG,TAG2,TAG3,TAG4

Is this possible?

So far, I have found a formula that partially works.

=IF(A1=A2,C1&","&C2)

Which gives me the following:

AAA  VALUE   TAG    TAG,TAG2
AAA  VALUE   TAG2   TAG2,TAG3
AAA  VALUE   TAG3   TAG3,TAG4
AAA  VALUE   TAG4   FALSE

To make it more complicated, sometimes there are only 2 rows where column A matches, and sometimes there are 5 or more where column A matches.

What can I do to make this work?

If your data is in A:C starting in Row2 with labels in Row1, enter =C2 in E2 and:

in D2: =IF(A2=A3,"",COUNTIF(A:A,A2)) and copy down
in E3: =IF(A2=A3,E2&", "&C3,C3) and copy down

then copy A:E to a new sheet and Paste Special Values there. Filter and select Blanks in ColumnD. Delete these and ColumnsC&D.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM