简体   繁体   English

用于合并行的Excel公式

[英]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) = 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. 更复杂的是,有时A列匹配的只有2行,有时A列匹配的只有5行或更多。

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: 如果您的数据是从第2行开始在A:C中且在第1行中带有标签,请在E2中输入= C2并:

in D2: =IF(A2=A3,"",COUNTIF(A:A,A2)) and copy down 在D2中: =IF(A2=A3,"",COUNTIF(A:A,A2))并向下复制
in E3: =IF(A2=A3,E2&", "&C3,C3) and copy down 在E3中: =IF(A2=A3,E2&", "&C3,C3)并向下复制

then copy A:E to a new sheet and Paste Special Values there. 然后将A:E复制到新工作表并在其中粘贴特殊值。 Filter and select Blanks in ColumnD. 过滤并在ColumnD中选择“空白”。 Delete these and ColumnsC&D. 删除这些和ColumnsC&D。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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