#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:
SectionIndexArray
1Sec_1A17:N31
2Sec_2A32:N46
3Sec_3A47:N61
4Sec_4A62:N76
5Sec_5A77:N91
6Sec_6A92:N106
7Sec_7A107:N121
8Sec_8A122:N136
9Sec_9A137:N151

<tbody>
</tbody>

<tbody>
</tbody>

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".
Duration​
10-DAY​
5-DAY​
72-HR​
48-HR​
24-HR​
18-HR​
12-HR​
6-HR​
3-HR​
2-HR​
1-HR​
30-MIN
15-MIN
10-MIN
5-MIN​

<tbody>
</tbody>

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)


SectionDuration2-MO3-MO4-MO6-MO9-MO1-YR2-YR5-YR10-YR25-YR50-YR100-YR
510-DAY2.22.643.053.584.124.485.26.227.228.619.6610.88
55-DAY1.762.112.392.773.183.464.054.945.726.927.989.18
572-HR1.511.7722.322.672.93.474.415.166.227.068.12
548-HR1.41.641.822.112.432.643.133.934.675.756.527.33
524-HR1.311.521.671.932.192.382.913.644.275.155.876.61
518-HR1.231.431.571.812.062.242.743.424.014.845.526.21
512-HR1.141.321.451.681.92.072.533.173.714.485.115.75
56-HR0.981.151.251.451.651.792.182.733.23.864.44.96
53-HR0.840.971.061.231.41.521.862.332.733.33.764.23
52-HR0.760.880.971.121.271.381.692.112.482.993.43.83
51-HR0.620.720.780.911.031.121.371.712.012.422.763.11
530-MIN0.480.560.620.710.810.881.081.351.581.912.172.45
515-MIN0.350.410.450.520.590.640.790.981.151.391.581.78
510-MIN0.280.320.350.410.460.50.610.760.91.081.231.39
55-MIN0.160.190.20.230.270.290.350.440.510.620.70.79

<tbody>
</tbody>
 
Last edited:

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
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,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

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