简体   繁体   中英

Excel INDEX MATCH formula for multiple rows

I have hit a problem with my Excel spreadsheet and am hoping for some guidance. 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 . 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.

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.

Any suggestions?

Match only works for 1 dimensional arrays, so we need to use something different.

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.

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.

If row 1:1 has number instead of text then we need to change all the "ZZZ" to 1E+99 . Then it will find the last column with numbers in row 1.

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