简体   繁体   English

使用 B 列数据将 A 列数据连接到 C 列

[英]Concatenate column A data into column C using column B data

在此处输入图片说明

Using if condition I need column A data to be concatenated according to column b.使用if条件我需要根据 b 列连接 A 列数据。 See column C for results.结果见 C 列。

Easy with a helper column.使用辅助栏很容易。 In D2 enter 1 and in D3 enter:D2 中输入1 ,在D3 中输入:

=IF(B3="","",ROW())

and copy downwards.并向下复制。 In C2 enter:C2 中输入:

=IF(B2="","",TEXTJOIN(" ",TRUE,INDEX($A$2:A2,MAX($D$1:D1)):A2))

and copy downwards:并向下复制:

在此处输入图片说明

This needs 3 columns:这需要 3 列:

Into column C, type:在 C 列中,键入:

=COUNTIF($B10:$B$10,">0")

at the bottom of the column, and drag upwards.在塔的底部,和向上拖动。 This counts the numbers in the range, and assigns each subrange a value.这会计算范围内的数字,并为每个子范围分配一个值。

Into column D, type:在 D 列中,键入:

=IF(C2<>C1,A2,CONCAT(D1," ",A2))

at the top of the column, and drag down.在列的顶部,然后向下拖动。 This concatenates each subrange.这将连接每个子范围。

Finally, into column E, type:最后,在 E 列中键入:

=IF(B2="","",D2)

at the top of the column, and drag down.在列的顶部,然后向下拖动。 This only shows the results we want.这仅显示了我们想要的结果。

Also, make sure there is a header or blank line at the start of the data.此外,请确保数据开头有标题或空行。

级联

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

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