Index-Match to select header value

MattChewy

New Member
Joined
Oct 1, 2015
Messages
23
Hi there,
Having trouble working out this index match scenario.
I have a long list of years and scores in column A and B.
I need to populate column C by copying down, with the correct category (low, med, high, very high) from the header in the second table, based on a match for the year, and then the approximate less than match.

My best shot is this logically: =INDEX($H$1:$K$1,MATCH(B2,$G$2:$G$27,0),MATCH(C2,$H$2:$K$27,1))
But I'm not sure a two-dimensional array for the column match is working...

Any ideas?


temp image share
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I didn't type in your whole table, and I changed a few values for testing. (For future reference, using the HTML Maker in my signature makes it much easier for people to import and test your data - it may help you get faster answers.)

ABCDEFGHIJK
1YearValueClassificationLowMedHighVery High
219900.295Low199000.4760.6210.727
319900.635High199100.4810.6270.728
419900.577Med199200.4820.6240.723
5199019930
6199019940
7199019950
819900.705High19960
919900.634High19970
1019900.866Very High19980
1119900.794Very High19990
12199020000
13199020010
1419910.745Very High20020
1519910.386Low20030
1619910.714High20040
17199120050
1819910.805Very High20060
1919910.648High20070
2019910.345Low20080
21

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet4

Worksheet Formulas
CellFormula
D2=IF(C2="","",INDEX($H$1:$K$1,MATCH(C2,OFFSET($H$2:$K$2,MATCH(B2,$G$2:$G$20,0)-1,0))))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>



But the D2 formula seems to do what you want. Let us know how it works for you.
 
Upvote 0
Hi Eric,
Thanks for the HTML maker link and the solution (works great).
Only things I don't quite understand in your formula is how the final INDEXing is grabbing the correct header category.

For D2, you go from this:
INDEX($H$1:$K$1,MATCH(C2,OFFSET($H$2:$K$2,MATCH(B2,$G$2:$G$20,0)-1,0)))

To the before last step in the calculation:
INDEX($H$1:$K$1,1)

Which selects "Low" correctly, however the INDEX formula is as such: INDEX( table, row_number, column_number ) and so your "1" is indicating the row_number. Shouldn't the "1" have to be in the column_number for the INDEX formula to return the correct category spread out across the columns?



I didn't type in your whole table, and I changed a few values for testing. (For future reference, using the HTML Maker in my signature makes it much easier for people to import and test your data - it may help you get faster answers.)

ABCDEFGHIJK
1YearValueClassificationLowMedHighVery High
219900.295Low199000.4760.6210.727
319900.635High199100.4810.6270.728
419900.577Med199200.4820.6240.723
5199019930
6199019940
7199019950
819900.705High19960
919900.634High19970
1019900.866Very High19980
1119900.794Very High19990
12199020000
13199020010
1419910.745Very High20020
1519910.386Low20030
1619910.714High20040
17199120050
1819910.805Very High20060
1919910.648High20070
2019910.345Low20080
21

<tbody>
</tbody>
Sheet4

Worksheet Formulas
CellFormula
D2=IF(C2="","",INDEX($H$1:$K$1,MATCH(C2,OFFSET($H$2:$K$2,MATCH(B2,$G$2:$G$20,0)-1,0))))

<tbody>
</tbody>

<tbody>
</tbody>



But the D2 formula seems to do what you want. Let us know how it works for you.
 
Upvote 0
INDEX is a pretty robust function, with lots of options. If you look at the documentation, it says that the column number OR the row number is optional. What this really boils down to is that if you give INDEX a 1-dimensional range (like $H$1:$K$1), vertically or horizontally, all you need is a single value to choose the element you want.

If you want, you certainly can change:

INDEX($H$1:$K$1,MATCH(C2,OFFSET($H$2:$K$2,MATCH(B2,$G$2:$G$20,0)-1,0)))

to

INDEX($H$1:$K$1,1,MATCH(C2,OFFSET($H$2:$K$2,MATCH(B2,$G$2:$G$20,0)-1,0)))

and it will work fine. It just depends on your style of designing formulas.
 
Upvote 0
Good to know. Didn't realize that the formula was flexible in that way.
Thanks again for the great formula.
 
Upvote 0
Hi there,

Using Eric's table; here's a formula without the OFFSET to prevent volatility, and to return an empty cell if there is no VALUE; formula in D2:

IF(ISBLANK(C2),"",INDEX($H$1:$K$1,MATCH(C2,INDEX($H$2:$K$21,MATCH(B2,$G$2:$G$21,0),0),1)))
 
Upvote 0

Forum statistics

Threads
1,214,980
Messages
6,122,563
Members
449,088
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top