简体   繁体   English

Excel INDEX MATCH公式用于多行

[英]Excel INDEX MATCH formula for multiple rows

I have hit a problem with my Excel spreadsheet and am hoping for some guidance. 我的Excel电子表格遇到问题,希望能提供一些指导。 I have a spreadsheet with multiple tabs, and in the "Matrix" tab I am trying to get cell B2 to Index the data 'Matrix Patch' Row 1:1 if there is a "1" in any cell in Rows 72:191 . 我有一个包含多个选项卡的电子表格,并且在“矩阵”选项卡中,如果Rows 72:191任何单元格中有“ 1”,我试图使单元格B2索引数据'Matrix Patch' Row 1:1 The current formula I am using is: 我正在使用的当前公式是:

=INDEX('Matrix Patch'!1:1,MATCH(1,'Matrix Patch'!72:191,0))

The answer I get is always N/A. 我得到的答案始终是N / A。

I can get it to work if I use: 我可以使用以下方法使其正常工作:

=INDEX('Matrix Patch'!1:1,MATCH(1,'Matrix Patch'!72:72,0))

but that only works if there is a "1" in Row 72. 但只有在第72行中的值为“ 1”时,此方法才有效。

Any suggestions? 有什么建议么?

Match only works for 1 dimensional arrays, so we need to use something different. Match仅适用于一维数组,因此我们需要使用其他方法。

Also any answer will be an array formula and we should limit it to the dataset columns, no full row references 另外,任何答案都是数组公式,我们应该将其限制为数据集列,没有完整的行引用

So we use the following: 因此,我们使用以下内容:

=INDEX('Matrix Patch'!A1:INDEX('Matrix Patch'!1:1,MATCH("ZZZ",'Matrix Patch'!1:1)),AGGREGATE(15,6,COLUMN('Matrix Patch'!A72:INDEX('Matrix Patch'!191:191,MATCH("ZZZ",'Matrix Patch'!1:1)))/('Matrix Patch'!A72:INDEX('Matrix Patch'!191:191,MATCH("ZZZ",'Matrix Patch'!1:1))),1))

This will return the first column that 1 is found in Row 72 to 91. 这将返回在72行到91行中找到1的第一列。

As stated before Array formulas should avoid full column or full row references in their calculations. 如前所述,数组公式在计算时应避免使用全列或全行引用。 I put in INDEX('Matrix Patch'!1:1,MATCH("ZZZ",'Matrix Patch'!1:1)) which finds the last column in row 1 that has text and set that as the last column in which to look. 我放入INDEX('Matrix Patch'!1:1,MATCH("ZZZ",'Matrix Patch'!1:1)) ,它找到第1行中具有文本的最后一列,并将其设置为其中的最后一列看。

If row 1:1 has number instead of text then we need to change all the "ZZZ" to 1E+99 . 如果行1:1具有数字而不是文本,那么我们需要将所有"ZZZ"更改为1E+99 Then it will find the last column with numbers in row 1. 然后,它将在第一行中找到带有数字的最后一列。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM