Nested VLOOKUP function #N/A error

jgmhunter

New Member
Joined
Aug 3, 2016
Messages
3
I have an old sheet that we use to compare values from multiple sites for each month of the year. I am sure there are ways of simplifying the formulas but I am just looking for a way to get it to return a "0" or blank value if the values are not found for a given site for the month selected. Here is the formula I am working with:

=IF($B$1="January",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,4,FALSE),IF($B$1="February",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,5,FALSE),IF($B$1="March",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,6,FALSE),IF($B$1="April",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,7,FALSE),IF($B$1="May",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,8,FALSE),IF($B$1="June",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,9,FALSE),IF($B$1="July",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,10,FALSE),IF($B$1="August",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,11,FALSE),IF($B$1="September",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,12,FALSE),IF($B$1="October",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,13,FALSE),IF($B$1="November",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,14,FALSE),IF($B$1="December",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,15,FALSE),""))))))))))))

I have tried variations of IFERROR or ISERROR and cannot seem to get it right.........
PLEASE HELP!!!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
IF($B$1="January", VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,4,FALSE),
IF($B$1="February",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,5,FALSE),
IF($B$1="March", VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,6,FALSE),
IF($B$1="April", VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,7,FALSE),
IF($B$1="May", VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,8,FALSE),
IF($B$1="June", VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,9,FALSE),
IF($B$1="July",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,10,FALSE),IF($B$1="August",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,11,FALSE),IF($B$1="September",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,12,FALSE),IF($B$1="October",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,13,FALSE),IF($B$1="November",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,14,FALSE),IF($B$1="December",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,15,FALSE),""))))))))))))

Looking at that, you could probably do that all with just 1 INDEX/MATCH/MATCH
 
Upvote 0
IF($B$1="January", VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,4,FALSE),
IF($B$1="February",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,5,FALSE),
IF($B$1="March", VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,6,FALSE),
IF($B$1="April", VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,7,FALSE),
IF($B$1="May", VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,8,FALSE),
IF($B$1="June", VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,9,FALSE),
IF($B$1="July",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,10,FALSE),IF($B$1="August",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,11,FALSE),IF($B$1="September",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,12,FALSE),IF($B$1="October",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,13,FALSE),IF($B$1="November",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,14,FALSE),IF($B$1="December",VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,15,FALSE),""))))))))))))

Looking at that, you could probably do that all with just 1 INDEX/MATCH/MATCH

Would that return a #N/A error if there is no value on the sheet?
 
Upvote 0
I would agree with Ford that an INDEX / MATCH is probably the way to go, but I think your formula could be changed to:
NOTE: IFERROR function only works in Excel 2010 or later.

Code:
=IFERROR(VLOOKUP("310100 SKILLED PRIVATE ROOM & BOARD",OPS,VLOOKUP(B1,{"January",4;"February",5;"March",6;"April",7;"May",8;"June",9;"July",10;"August",11;"September",12;"October",13;"November",14;"December",15},2,0),FALSE),"")
 
Upvote 0
See if you can adapt this (and yes, it will return an error if not found)...
A​
B​
C​
D​
E​
F​
G​
1​
JanfebMarAprMayJun
2​
aa
1​
10​
100​
1000​
10000​
100000​
3​
bb
2​
20​
200​
2000​
20000​
200000​
4​
cc
3​
30​
300​
3000​
30000​
300000​
5​
dd
4​
40​
400​
4000​
40000​
400000​
6​
ee
5​
50​
500​
5000​
50000​
500000​
7​
ff
6​
60​
600​
6000​
60000​
600000​
8​
gg
7​
70​
700​
7000​
70000​
700000​
9​
hh
8​
80​
800​
8000​
80000​
800000​
10​
ii
9​
90​
900​
9000​
90000​
900000​
11​
jj
10​
100​
1000​
10000​
100000​
1000000​
12​
13​
14​
Find
15​
aa
16​
Mar
17​
100​
18​
19​
aa
20​
Marr
21​
#N/A​
A17=INDEX($B$2:$G$11,MATCH(A15,$A$2:$A$11,0),MATCH(A16,$B$1:$G$1,0))

A21=INDEX($B$2:$G$11,MATCH(A19,$A$2:$A$11,0),MATCH(A20,$B$1:$G$1,0))
This is what it would look like if no match was found
If you have a version earier than 2007, this will fox that...
=IF(ISERROR(INDEX($B$2:$G$11,MATCH(A19,$A$2:$A$11,0),MATCH(A20,$B$1:$G$1,0))),"",INDEX($B$2:$G$11,MATCH(A19,$A$2:$A$11,0),MATCH(A20,$B$1:$G$1,0)))

If you have 2007 or later...
=IFERROR(INDEX($B$2:$G$11,MATCH(A19,$A$2:$A$11,0),MATCH(A20,$B$1:$G$1,0)))
 
Upvote 0
That's what the above formula does. It looks at the month in B1 and changes the column index number to 4,5,6 etc. depending on the month.
You could also use the MATCH function to look for the column header, if you have the months in the header row.
 
Upvote 0

Forum statistics

Threads
1,216,384
Messages
6,130,309
Members
449,571
Latest member
Jay Zyller

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