Nested Ifs Based on the Calendar Year

tycasey17

Board Regular
Joined
Sep 26, 2013
Messages
93
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
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

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Why not simply
IF(A1=2019,VLOOKUP(A2,B2:D10,2,FALSE),IF(A1=2020,VLOOKUP(A2,B2:D10,3,FALSE),""))
 
Upvote 0
There will be more than just two arguments, it will end up being about five per year so I see what you mean.
 
Upvote 0
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:


Book1
ABCDEFG
120192YESYES
2somethisab
3thatbc^Your formulaShortened using B1
4someyesno
5othercd
6yesde
7noef
8maybefg
9highgh
10lowhi
Sheet554
Cell Formulas
RangeFormula
B1=IF(A1=2019,2,IF(A1=2020,3,""))
F1=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","")),""))
G1=IFERROR(IF(VLOOKUP(A2,B2:D10,B1,FALSE)="YES","YES",IF(VLOOKUP(A2,B2:D10,B1,FALSE)="NO","NO","")),"")
 
Last edited:
Upvote 0
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","")),"")
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,198
Members
452,616
Latest member
intern444

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