Avatar of Tom Crowfoot
Tom Crowfoot
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Excel Formula return value based on current month

Hi Experts

I have a formula that is supposed to show certain results based on which month we're currently in, but it doesn't seem to update & I am getting no error message.  The formula should read "IF todays month is January (1) then return the value from cell C4 in the tab January, if not then if todays month is February (2) then return the value from cell C4 in the tab February


=IF(MONTH(NOW()=1),January!C4,IF(MONTH(NOW()=2),February!C4,IF(MONTH(NOW()=2),March!C4,IF(MONTH(NOW()=4),April!C4,IF(MONTH(NOW()=5),May!C4,IF(MONTH(NOW()=6),June!C4,IF(MONTH(NOW()=7),July!C4,IF(MONTH(NOW()=8),August!C4,IF(MONTH(NOW()=9),September!C4,IF(MONTH(NOW()=10),October!C4,IF(MONTH(NOW()=11),November!C4,IF(MONTH(NOW()=12),December!C4,"xxx"))))))))))))


Microsoft ExcelMicrosoft Office

Avatar of undefined
Last Comment
byundt

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Tom Crowfoot

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
byundt

With all due respect, your simplified formula is fatally flawed.

The Boolean expression $A$1=a number 1 through 12 will return either TRUE or FALSE. But the MONTH function surrounding is a problem because MONTH(TRUE) and MONTH(FALSE) both return 1. Your formula will therefore always return January!A2.

Please consider using a formula like:
=IFERROR(INDIRECT(TEXT(NOW(),"mmmm") & "!A2"),"")

Open in new window

If you don't need to worry about a worksheet for a given month not being present, you could shorten the above formula to:
=INDIRECT(TEXT(NOW(),"mmmm""!A2"""))

Open in new window

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck