#N/A Error on complicated Index/Match

bigmyk2k

Board Regular
Joined
Feb 9, 2012
Messages
104
(See this forum for the first steps, and what has already been tried)

I am trying to do a complicated Index function where I am doing an INDIRECT(VLOOKUP(... for the Array, a MATCH for the Row Number, and (I think) a MATCH for the Column.

=INDEX(INDIRECT(VLOOKUP($D$2,Section,2,FALSE)),MATCH($B$10,Duration,0),Match($B$9,...?)

Where-
$D$2 refers to the known (user input) section number, in this case: 5
$B$10 refers to the known period of duration (user input), in this case: 24-HR
$B$9 refers to the recorded precip. value (user input), in this case: 1.72​

The Indirect Lookup is finding an array based on a cell which refers to a named list ("Section").
This is in place because the data is identified by the first column of each named array which includes the section number of the data. The "Section" array is:
[TABLE="width: 108"]
<tbody>[TR]
[TD="class: xl67, width: 54"]
[TABLE="width: 183"]
<tbody>[TR]
[TD]Section[/TD]
[TD]Index[/TD]
[TD]Array[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Sec_1[/TD]
[TD]A17:N31[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Sec_2[/TD]
[TD]A32:N46[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Sec_3[/TD]
[TD]A47:N61[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Sec_4[/TD]
[TD]A62:N76[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Sec_5[/TD]
[TD]A77:N91[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]Sec_6[/TD]
[TD]A92:N106[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]Sec_7[/TD]
[TD]A107:N121[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]Sec_8[/TD]
[TD]A122:N136[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]Sec_9[/TD]
[TD]A137:N151[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD="class: xl67, width: 54"][/TD]
[/TR]
</tbody>[/TABLE]

The Row is found by matching a value found in the column headed as Duration to the value in a named array, also confusingly named, "Duration".
[TABLE="width: 54"]
<tbody>[TR]
[TD="align: center"]
Duration​
[/TD]
[/TR]
[TR]
[TD="align: center"]
10-DAY​
[/TD]
[/TR]
[TR]
[TD="align: center"]
5-DAY​
[/TD]
[/TR]
[TR]
[TD="align: center"]
72-HR​
[/TD]
[/TR]
[TR]
[TD="align: center"]
48-HR​
[/TD]
[/TR]
[TR]
[TD="align: center"]
24-HR​
[/TD]
[/TR]
[TR]
[TD="align: center"]
18-HR​
[/TD]
[/TR]
[TR]
[TD="align: center"]
12-HR​
[/TD]
[/TR]
[TR]
[TD="align: center"]
6-HR​
[/TD]
[/TR]
[TR]
[TD="align: center"]
3-HR​
[/TD]
[/TR]
[TR]
[TD="align: center"]
2-HR​
[/TD]
[/TR]
[TR]
[TD="align: center"]
1-HR​
[/TD]
[/TR]
[TR]
[TD="align: center"]
30-MIN
15-MIN
10-MIN
5-MIN​
[/TD]
[/TR]
</tbody>[/TABLE]

What I need to do now is find how to have the function call out the column(s) that bound a lookup value.

For instance, in the example table (below), a reference 24-HR value of 1.72 would be greater than 1.67 (4-MO), and less than 1.93 (6-MO). I know that this is two different lookups, and that is how I want it.

My ultimate goal will be to return all four of those things (1.67, "4-MO", 1.93, "6-MO") in individual cells, but I think finding either the values or the "X-MO" reference will facilitate the other.

Note that the column headers in this table are in A16:N16, whereas the values listed are from the array referenced above ("Sec_5", in A77:N91)


[TABLE="width: 806"]
<tbody>[TR]
[TD="align: center"]Section[/TD]
[TD="align: center"]Duration[/TD]
[TD="align: center"]2-MO[/TD]
[TD="align: center"]3-MO[/TD]
[TD="align: center"]4-MO[/TD]
[TD="align: center"]6-MO[/TD]
[TD="align: center"]9-MO[/TD]
[TD="align: center"]1-YR[/TD]
[TD="align: center"]2-YR[/TD]
[TD="align: center"]5-YR[/TD]
[TD="align: center"]10-YR[/TD]
[TD="align: center"]25-YR[/TD]
[TD="align: center"]50-YR[/TD]
[TD="align: center"]100-YR[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]10-DAY[/TD]
[TD="align: center"]2.2[/TD]
[TD="align: center"]2.64[/TD]
[TD="align: center"]3.05[/TD]
[TD="align: center"]3.58[/TD]
[TD="align: center"]4.12[/TD]
[TD="align: center"]4.48[/TD]
[TD="align: center"]5.2[/TD]
[TD="align: center"]6.22[/TD]
[TD="align: center"]7.22[/TD]
[TD="align: center"]8.61[/TD]
[TD="align: center"]9.66[/TD]
[TD="align: center"]10.88[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]5-DAY[/TD]
[TD="align: center"]1.76[/TD]
[TD="align: center"]2.11[/TD]
[TD="align: center"]2.39[/TD]
[TD="align: center"]2.77[/TD]
[TD="align: center"]3.18[/TD]
[TD="align: center"]3.46[/TD]
[TD="align: center"]4.05[/TD]
[TD="align: center"]4.94[/TD]
[TD="align: center"]5.72[/TD]
[TD="align: center"]6.92[/TD]
[TD="align: center"]7.98[/TD]
[TD="align: center"]9.18[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]72-HR[/TD]
[TD="align: center"]1.51[/TD]
[TD="align: center"]1.77[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]2.32[/TD]
[TD="align: center"]2.67[/TD]
[TD="align: center"]2.9[/TD]
[TD="align: center"]3.47[/TD]
[TD="align: center"]4.41[/TD]
[TD="align: center"]5.16[/TD]
[TD="align: center"]6.22[/TD]
[TD="align: center"]7.06[/TD]
[TD="align: center"]8.12[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]48-HR[/TD]
[TD="align: center"]1.4[/TD]
[TD="align: center"]1.64[/TD]
[TD="align: center"]1.82[/TD]
[TD="align: center"]2.11[/TD]
[TD="align: center"]2.43[/TD]
[TD="align: center"]2.64[/TD]
[TD="align: center"]3.13[/TD]
[TD="align: center"]3.93[/TD]
[TD="align: center"]4.67[/TD]
[TD="align: center"]5.75[/TD]
[TD="align: center"]6.52[/TD]
[TD="align: center"]7.33[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]24-HR[/TD]
[TD="align: center"]1.31[/TD]
[TD="align: center"]1.52[/TD]
[TD="align: center"]1.67[/TD]
[TD="align: center"]1.93[/TD]
[TD="align: center"]2.19[/TD]
[TD="align: center"]2.38[/TD]
[TD="align: center"]2.91[/TD]
[TD="align: center"]3.64[/TD]
[TD="align: center"]4.27[/TD]
[TD="align: center"]5.15[/TD]
[TD="align: center"]5.87[/TD]
[TD="align: center"]6.61[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]18-HR[/TD]
[TD="align: center"]1.23[/TD]
[TD="align: center"]1.43[/TD]
[TD="align: center"]1.57[/TD]
[TD="align: center"]1.81[/TD]
[TD="align: center"]2.06[/TD]
[TD="align: center"]2.24[/TD]
[TD="align: center"]2.74[/TD]
[TD="align: center"]3.42[/TD]
[TD="align: center"]4.01[/TD]
[TD="align: center"]4.84[/TD]
[TD="align: center"]5.52[/TD]
[TD="align: center"]6.21[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]12-HR[/TD]
[TD="align: center"]1.14[/TD]
[TD="align: center"]1.32[/TD]
[TD="align: center"]1.45[/TD]
[TD="align: center"]1.68[/TD]
[TD="align: center"]1.9[/TD]
[TD="align: center"]2.07[/TD]
[TD="align: center"]2.53[/TD]
[TD="align: center"]3.17[/TD]
[TD="align: center"]3.71[/TD]
[TD="align: center"]4.48[/TD]
[TD="align: center"]5.11[/TD]
[TD="align: center"]5.75[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]6-HR[/TD]
[TD="align: center"]0.98[/TD]
[TD="align: center"]1.15[/TD]
[TD="align: center"]1.25[/TD]
[TD="align: center"]1.45[/TD]
[TD="align: center"]1.65[/TD]
[TD="align: center"]1.79[/TD]
[TD="align: center"]2.18[/TD]
[TD="align: center"]2.73[/TD]
[TD="align: center"]3.2[/TD]
[TD="align: center"]3.86[/TD]
[TD="align: center"]4.4[/TD]
[TD="align: center"]4.96[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]3-HR[/TD]
[TD="align: center"]0.84[/TD]
[TD="align: center"]0.97[/TD]
[TD="align: center"]1.06[/TD]
[TD="align: center"]1.23[/TD]
[TD="align: center"]1.4[/TD]
[TD="align: center"]1.52[/TD]
[TD="align: center"]1.86[/TD]
[TD="align: center"]2.33[/TD]
[TD="align: center"]2.73[/TD]
[TD="align: center"]3.3[/TD]
[TD="align: center"]3.76[/TD]
[TD="align: center"]4.23[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]2-HR[/TD]
[TD="align: center"]0.76[/TD]
[TD="align: center"]0.88[/TD]
[TD="align: center"]0.97[/TD]
[TD="align: center"]1.12[/TD]
[TD="align: center"]1.27[/TD]
[TD="align: center"]1.38[/TD]
[TD="align: center"]1.69[/TD]
[TD="align: center"]2.11[/TD]
[TD="align: center"]2.48[/TD]
[TD="align: center"]2.99[/TD]
[TD="align: center"]3.4[/TD]
[TD="align: center"]3.83[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]1-HR[/TD]
[TD="align: center"]0.62[/TD]
[TD="align: center"]0.72[/TD]
[TD="align: center"]0.78[/TD]
[TD="align: center"]0.91[/TD]
[TD="align: center"]1.03[/TD]
[TD="align: center"]1.12[/TD]
[TD="align: center"]1.37[/TD]
[TD="align: center"]1.71[/TD]
[TD="align: center"]2.01[/TD]
[TD="align: center"]2.42[/TD]
[TD="align: center"]2.76[/TD]
[TD="align: center"]3.11[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]30-MIN[/TD]
[TD="align: center"]0.48[/TD]
[TD="align: center"]0.56[/TD]
[TD="align: center"]0.62[/TD]
[TD="align: center"]0.71[/TD]
[TD="align: center"]0.81[/TD]
[TD="align: center"]0.88[/TD]
[TD="align: center"]1.08[/TD]
[TD="align: center"]1.35[/TD]
[TD="align: center"]1.58[/TD]
[TD="align: center"]1.91[/TD]
[TD="align: center"]2.17[/TD]
[TD="align: center"]2.45[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]15-MIN[/TD]
[TD="align: center"]0.35[/TD]
[TD="align: center"]0.41[/TD]
[TD="align: center"]0.45[/TD]
[TD="align: center"]0.52[/TD]
[TD="align: center"]0.59[/TD]
[TD="align: center"]0.64[/TD]
[TD="align: center"]0.79[/TD]
[TD="align: center"]0.98[/TD]
[TD="align: center"]1.15[/TD]
[TD="align: center"]1.39[/TD]
[TD="align: center"]1.58[/TD]
[TD="align: center"]1.78[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]10-MIN[/TD]
[TD="align: center"]0.28[/TD]
[TD="align: center"]0.32[/TD]
[TD="align: center"]0.35[/TD]
[TD="align: center"]0.41[/TD]
[TD="align: center"]0.46[/TD]
[TD="align: center"]0.5[/TD]
[TD="align: center"]0.61[/TD]
[TD="align: center"]0.76[/TD]
[TD="align: center"]0.9[/TD]
[TD="align: center"]1.08[/TD]
[TD="align: center"]1.23[/TD]
[TD="align: center"]1.39[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]5-MIN[/TD]
[TD="align: center"]0.16[/TD]
[TD="align: center"]0.19[/TD]
[TD="align: center"]0.2[/TD]
[TD="align: center"]0.23[/TD]
[TD="align: center"]0.27[/TD]
[TD="align: center"]0.29[/TD]
[TD="align: center"]0.35[/TD]
[TD="align: center"]0.44[/TD]
[TD="align: center"]0.51[/TD]
[TD="align: center"]0.62[/TD]
[TD="align: center"]0.7[/TD]
[TD="align: center"]0.79[/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Is this now an accurate and consistent representation of your 'real' data setup?
Each section is 15 rows, every 15 rows, always every 15 rows?

The last formula I posted in your other thread (Post #16) works just fine for that.
You only needed to change the C10 to B9

But here's another way as well without the need for all the named ranges (except Duration) and indirect/vlookup.

Try this.

=LOOKUP($B$9,OFFSET($C$17,($D$2-1)*15+MATCH($B$10,Duration,0)-1,0,1,12))
 
Last edited:
Upvote 0
If you wanted to get the "4-MO" value, we can just add the header row C16:N14 as the last argument of the lookup)

=LOOKUP($B$9,OFFSET(C17,($D$2-1)*15+MATCH($B$10,Duration,0)-1,0,1,12),$C$16:$N$16)

or from the other thread
=LOOKUP($B$9,OFFSET(INDEX(INDIRECT(VLOOKUP($D$2,Section,2,FALSE)),MATCH($B$10,Duration,0),3),,,1,12),$C$16:$N$16)
 
Last edited:
Upvote 0
=LOOKUP($B$9,OFFSET(INDEX(INDIRECT(VLOOKUP($D$2,Section,2,FALSE)),MATCH($B$10,Duration,0),3),,,1,12),$C$16:$N$16)

Eureka!
Now, that's the one!!
Though, I did change the Header reference slightly:
=LOOKUP($B$9,OFFSET(INDEX(INDIRECT(VLOOKUP($D$2,Section,2,FALSE)),MATCH($B$10,Duration,0),3),,,1,12),Table1[[#Headers],[2-MO]:[100-YR]])

Having now worked through the whole thing, I learned a lot about Excel that I thought I already knew.
One more question, how would I then look up the upper bounding value? That is, 1.72 is greater than the 4-MO value, which we looked up, but less than the 6-MO value of 1.93. How do we tweak this to return "6-MO"?

I thought it would be in changing the [Match Type] but that doesn't seem to work.
 
Upvote 0
Offset the table headers by 1 column..

=LOOKUP($B$9,OFFSET(INDEX(INDIRECT(VLOOKUP($D$2,Section,2,FALSE)),MATCH($B$10,Duration,0),3),,,1,12),$C$16:$N$16) = "4-MO"
=LOOKUP($B$9,OFFSET(INDEX(INDIRECT(VLOOKUP($D$2,Section,2,FALSE)),MATCH($B$10,Duration,0),3),,,1,12),$D$16:$O$16) = "6-MO"

Or better, no need to do the whole formula twice...
You can then index the header range looking up the result of the first formula, and adding 1..
something like
=INDEX($C$16:$N$16,MATCH($B$11,$C$16:$N$16,0)+1)

Where B11 is the cell holding the formula that returns "4-MO"
 
Upvote 0
Or better, no need to do the whole formula twice...
You can then index the header range looking up the result of the first formula, and adding 1..
something like
=INDEX($C$16:$N$16,MATCH($B$11,$C$16:$N$16,0)+1)

Where B11 is the cell holding the formula that returns "4-MO"

You're making this too easy.
 
Upvote 0
Note, that method will error if the result of the first formula is 100-YR
Because there is no column header to the right of that.

You'd have to add an IFERROR
=IFERROR(INDEX($C$16:$N$16,MATCH($B$11,$C$16:$N$16,0)+1),"No Header Value after 100-YR")
 
Upvote 0
Note, that method will error if the result of the first formula is 100-YR
Because there is no column header to the right of that.

You'd have to add an IFERROR
=IFERROR(INDEX($C$16:$N$16,MATCH($B$11,$C$16:$N$16,0)+1),"No Header Value after 100-YR")

Yeah, and also if a value is less than "2-MO". I did see that one coming, and fortunately I'm good with really unnecessarily complicated IF statements.
 
Upvote 0
Yeah, and also if a value is less than "2-MO".
You should add another column to the 'Sections' to include add a column of 0's to the left of the 2-MO column...
And you'd have to change the 12 in that formula to 13.
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,126
Members
452,381
Latest member
Nova88

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