简体   繁体   English

如何根据 Google 表格中相邻列中的值返回一系列单元格

[英]How to return a range of cells based on a value in the adjacent column in Google Sheets

I'd like to write a formula to such that it returns a range of cells from column H (unique ID) based on a criterion that is the value in column G (parent manual id).我想编写一个公式,使其根据 G 列(父手册 ID)中的值的标准从 H 列(唯一 ID)返回一系列单元格。 So for eg the formula should return a range of all the cells highlighted in yellow (from the image below) when the criteria in the adjacent column (column G) is 1. Similarly, the formula should return a range of all the cells highlighted in blue when the criterion (column G) is 2, and so on.因此,例如,当相邻列(G 列)中的标准为 1 时,公式应返回以黄色突出显示的所有单元格的范围(如下图)。类似地,公式应返回突出显示的所有单元格的范围当标准(G 列)为 2 时为蓝色,依此类推。

The reason, I need this to be a range of cells, is because I need to pass this resultant range as an argument into another formula (a TEXTJOIN function).原因,我需要这是一个单元格范围,因为我需要将此结果范围作为参数传递给另一个公式(TEXTJOIN 函数)。

参考表

Use a query function.使用查询 function。 Make a helper column I with all unique parent manual ids column G --> unique(G2:G)使用所有唯一的父手册 ID 列 G --> unique(G2:G)创建一个辅助列 I

Then for the textjoin column:然后对于 textjoin 列:

=TEXTJOIN(" ",TRUE,QUERY(G$2:$H,"SELECT H WHERE G="&I2))

在此处输入图像描述

use FILTER使用FILTER

=FILTER(H:H; G:G=1)

and:和:

=FILTER(H:H; G:G=2)

and then do your TEXTJOIN for csv:然后为 csv 执行TEXTJOIN

=TEXTJOIN(", "; 1; FILTER(H:H; G:G=1))

or perhaps for regex:或者也许对于正则表达式:

=TEXTJOIN("|"; 1; FILTER(H:H; G:G=2))

暂无
暂无

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

相关问题 如果单元格范围中的日期是今天在Google表格中,如何返回单元格值 - How to return a cell value if the date in a range of cells is today in google sheets Google 表格:如何根据匹配整个范围的列返回文本值? - Google sheets: How do I return a text value based on a column matching an entire range? 如何循环单元格范围并在相邻列中设置值 - How to loop range of cells and set value in adjacent column Google表格:有条件地将一列单元格格式化为相邻的单元格(列) - Google Sheets: Conditional formatting a column of cells to an adjacent cell(column) 如何在 Google 表格中返回以逗号分隔的单元格范围字符串? - How to return comma-delimited string of range of cells in Google Sheets? Google Sheets - 根据相应单元格范围内的数值连接单元格范围内文本的公式 - Google Sheets - Formula to Concatenate Text in Range of Cells based on Numeric Value in Corresponding Range of Cells Google表格会返回基于值的范围内的一系列连接值 - Google sheets return a string of concatenated values from a range based on value 根据 Google 表格中的两列匹配返回第三列的值 - Return value of third column based on two column matches in Google Sheets 如何从谷歌表格中另一个单元格的相邻单元格中分配变量的值 - How to assign a the value of a variable from the adjacent cells of another cell in google sheets 如何根据 Google 表格上的水平查找返回动态范围? - How to return a dynamic range based on a horizontal lookup on Google Sheets?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM