简体   繁体   中英

Excel formula to Concatenate multiple values from columns based on criteria

I need to concatenate values (header + value) from about 150 columns.

This is the formula that I used: =IF(B2<>0,$B$1&": "&B2,"")&" " &IF(C2<>0,$C$1&": "&C2,"") This is just an example and it just concatenates values from two columns.

Do you have any ideas how to write the formula so that it concatenates values from 150 columns easily - based on my criteria, which is: value <> 0.

This is just a sample data:

在此处输入图像描述

As JvdV suggested, if you have TEXTJOIN() formula then could try-

=TEXTJOIN(" ",TRUE,IF(B2:E2<>0,$B$1:$E$1 & ":" & B2:E2,""))

You may need to array entry for non-365 version of excel. Array entry means put formula to cell then press CTRL + SHIFT + ENTER .

在此处输入图像描述

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