简体   繁体   中英

How to concatenate a column value based on another column value in excel?

I have sheet like this :

图片1

How can I concatenate values in column B based on value in column A .

Values corresponding to ID 1.1.1 are of B2:B5 Similarly, values for ID 1.1.2 are of B6:B8 and so on.. Its like it start from first id, lookup until next id, all values in column B until next Id in column A is concatenated

the result should be like this : 2,3,4,5 in single cell of column D

I am not sure if this would solve your purpose, but you can keep concatenating values till the value in column A is same and use the last value.

Assuming the case you provided, paste the formula =IF(A2<>"",B2,D1&", "&B2) in cell D2 and copy throughout the column. You can additionally create a flag for changes in column E using =IF(A2<>"",1,"") in cell E2 . The results would be like this.

样本输出

It's still not quite clear, what you are trying to achieve, but to simply concatenate columns with a comma as separator, you can try something like the following:

In column d2 (or column d5), type in the following formula

=B2&","&B3&","&B4&","&B5

That should get you in the right direction.

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