简体   繁体   English

Google Sheets - 根据相应单元格范围内的数值连接单元格范围内文本的公式

[英]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:我在 Google 表格中有这个设置:

谷歌表格设置

Row 1 is a list of ingredients.第 1 行是成分列表。 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.第 2-6 行是包含成分 AF 组合的特定计划 - 如果列中有 1,则它包含列中的成分。

In column H, I want to concatenate the letters in row 1 if there is a 1 underneath it.在 H 列中,如果下面有一个 1,我想连接第 1 行中的字母。 So the formula I'm looking for in Col H should spit out the following:所以我在 Col H 中寻找的公式应该吐出以下内容:

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

I've tried the TEXTJOIN formula you see in the formula bar but it's not working.我已经尝试了您在公式栏中看到的 TEXTJOIN 公式,但它不起作用。 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 .如果我正确理解了您想要组合的内容,另一种选择是使用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).我需要合并 5 列,但在单元格包含特定数据时做笔记(例如,当 X 在单元格中时,不是合并列而是写注释)。 And the combination of CONCATENATE + IF worked.并且 CONCATENATE + IF 的组合有效。

I found this solution here .我在这里找到了这个解决方案。

Hope it'll be somehow helpful :)希望它会有所帮助:)

暂无
暂无

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

相关问题 是否有一个谷歌表格公式可以采用一系列单元格,并按字母顺序在一个单独的列中列出所有单元格? - Is there a Google Sheets formula that can take a range of cells, and list all the cells in one separate column, alphabetically? Google 表格:条件格式 - 根据另一个单元格的值在一个范围内为一行中的所有非空单元格着色? - Google Sheets: Conditional Formatting - color all non-empty cells in a row within a range based on the value of another cell? 扩展 RegexMatch 以针对整个单元格范围进行测试 - Google Sheets - Expand RegexMatch To Test Against An Entire Range Of Cells - Google Sheets 写入Google表格中的单元格时出现错误的范围错误 - Incorrect Range Error when writing to cells in google sheets 使用Google表格中某个范围内的map()发出阅读单元格的问题 - Issues reading cells using map() in a range in Google Sheets Excel:仅根据一个单元格的值或公式填充一系列单元格 - Excel: Fill a range of cells with a value or formula depending on only one cell 仅从 Google 表格中的函数返回一系列单元格(在所需的索引范围内) - Return only a range of cells (within desired index range) from a function in Google Sheets 从谷歌应用脚本中的一系列单元格中获取每个单元格值 - Getting each cell value from a range of cells in google app script 谷歌表数组公式拆分和导入范围 - google sheets array formula split and import range 如何在 Google 表格中的 importxml 公式中定义范围 - How to define range in importxml formula in Google Sheets
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM