[英]How to collect data and headers for non blank cells in a row in Sheets
I cannot find a solution to my problem:我找不到解决我的问题的方法:
I have a sheet with ~290 rows and ~80 columns.我有一张约 290 行和约 80 列的工作表。 The first row and column are fixed/header.第一行和第一列是固定/标题。
I would like to collect non-blank values and their header into column B.我想将非空白值及其标题收集到 B 列中。
I've tried to search for solutions, but I'm not as good at excel, so I cannot wrap my head around most of the advice that I've found.我试图寻找解决方案,但我不擅长 excel,所以我无法理解我找到的大部分建议。
In Google Sheets you could use an Array formula.在 Google 表格中,您可以使用数组公式。 I got this:我懂了:
The formula I've used:我用过的公式:
=ArrayFormula(CONCATENATE(IF(--(C2:G2<>"")*COLUMN($C$1:$G$1)<>0;$C$1:$G$1&" "&C2:G2;"")))
This is how it works:这是它的工作原理:
(--(C2:G2<>"")
will return an array of 0 and 1 if the cell is blank or not (--(C2:G2<>"")
将返回一个由 0 和 1 组成的数组,如果单元格是否为空COLUMN($C$1:$G$1)
will return an array of column numbers of each cell COLUMN($C$1:$G$1)
将返回每个单元格的列号数组(C2:G2<>"")*COLUMN($C$1:$G$1)
we multiply both arrays, so we will get an array of column numbers of non blank cells and 0 of blank cells (C2:G2<>"")*COLUMN($C$1:$G$1)
我们将两个数组相乘,所以我们将得到一个非空白单元格列号和空白单元格 0 的数组<>0;$C$1:$G$1&" "&C2:G2;"")
We check if each number in the array obtained in step 3 is 0 or not. <>0;$C$1:$G$1&" "&C2:G2;"")
我们检查步骤 3 中获得的数组中的每个数字是否为 0。 If it's 0, it returns a null value, if not, it returns the value of cell如果为 0,则返回空值,如果不是,则返回单元格的值CONCATENATE
will concatenate all values from previous array (step 4) so we concatenate null values with real values of non blank cells. CONCATENATE
将连接前一个数组中的所有值(步骤 4),因此我们将空值与非空白单元格的实际值连接起来。Not sure if this will make the sheet load slower if you have too many records.如果您有太多记录,不确定这是否会使工作表加载速度变慢。
Hope this helps希望这可以帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.