# Nested Ifs Based on the Calendar Year

#### tycasey17

##### Board Regular
I have been trying to have a nested IF statement based on the year. It seems like the year portion is causing the issue but I cannot seem how to fix this, I am trying to have multiple years on the same sheet but have a formula to pull up by the year I select.

SAMPLE FORMULA:
IF(A1="2019",
IF(VLOOKUP(A2,B2:D10,2,FALSE)="YES","YES",
IF(VLOOKUP(A2,B2:D10,2,FALSE)="NO","NO","")),
IF(A1="2020",
IF(VLOOKUP(A2,B2:D10,3,FALSE)="YES","YES",
IF(VLOOKUP(A2,B2:D10,3,FALSE)="NO","NO","")),""))

### Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

#### Fluff

##### MrExcel MVP, Moderator
Why not simply
IF(A1=2019,VLOOKUP(A2,B2:D10,2,FALSE),IF(A1=2020,VLOOKUP(A2,B2:D10,3,FALSE),""))

#### tycasey17

##### Board Regular
There will be more than just two arguments, it will end up being about five per year so I see what you mean.

#### jtakw

##### Well-known Member
Hi,

If you have the Year as a Number (Not Text) in A1, have you removed the quote marks around "2019", and "2020" in your formula like Fluff show in Post # 2 ?
If you have, then it should work.

Also, if you use a "Helper Cell" to convert the Year in A1 (2019, 2020) to 2, 3 respectively, your formula can be cut in half (or more), if you add more years, (i.e. 2019, 2020, 2021, 2022 to 2, 3, 4, 5).

See below sample:

Last edited:

#### Fluff

##### MrExcel MVP, Moderator
Or without a helper cell
=IFERROR(IF(VLOOKUP(A2,B2:D10,A1-2017,0)="yes","YES",IF(VLOOKUP(A2,B2:D10,A1-2017,0)="no","NO","")),"")

Replies
3
Views
24
Replies
4
Views
96
Replies
4
Views
223
Replies
11
Views
98
Replies
8
Views
258

1,130,446
Messages
5,642,204
Members
417,261
Latest member
andrewd1

### 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.

### Which adblocker are you using?

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

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