简体   繁体   中英

Google Sheets - Formula to Concatenate Text in Range of Cells based on Numeric Value in Corresponding Range of Cells

I have this setup in Google Sheets:

谷歌表格设置

Row 1 is a list of ingredients. Rows 2-6 are specific plans that contain combinations of ingredients AF - if there is a 1 in the column, it contains the ingredient in the column.

In column H, I want to concatenate the letters in row 1 if there is a 1 underneath it. So the formula I'm looking for in Col H should spit out the following:

  1. Cell H2 --> A + B
  2. Cell H3 --> A + C
  3. Cell H4 --> A + B + D
  4. Cell H5 --> A + C + D
  5. Cell H6 --> A

I've tried the TEXTJOIN formula you see in the formula bar but it's not working. Can anyone help with this?

Thanks!

Nevermind, I just figured it out. I had to change my formula above to:

=textjoin(" + ", TRUE, arrayformula(IF($B7:$G7=1, $B$1:$G$1,"")))

Anthony,

If I got it correctly what you want to combine, another option to do that is to use CONCATENATE + IF .

I needed to combine 5 columns but make a note while a cell contains particular data (eg, when X is in the cell, not to combine columns but write a comment). And the combination of CONCATENATE + IF worked.

I found this solution here .

Hope it'll be somehow helpful :)

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