Conditional format if date values from two cells are within Qtr/Year Range

lewjan

New Member
Joined
Dec 4, 2020
Messages
11
Office Version
  1. 2010
Platform
  1. Windows
Hello,
Thanks in advance for your help! I am looking for macro/vba to help highlight a range of cells within the quarter/year columns if date value falls within baseline start and baseline end?


baseline startbaseline end2021 Q12021 Q22021 Q32021 Q42022 Q12022 Q22022 Q32022 Q4
apple
25-Feb-21​
30-Dec-21​
fill in green colorfill in green colorfill in green colorfill in green color
orange
30-Apr-21​
30-May-22​
fill in green colorfill in green colorfill in green colorfill in green colorfill in green color

Grateful for your help!
Jan
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
No VBA, and added a helper row.
MrExcelPlayground.xlsm
ABCDEFGHIJK
11/1/20214/1/20217/1/202110/1/20211/1/20224/1/20227/1/202210/1/2022
2baseline startbaseline end2021 Q12021 Q22021 Q32021 Q42022 Q12022 Q22022 Q32022 Q4
3apple2/25/202112/31/2021
4orange4/30/20215/30/2022
Sheet49
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D3:K4Expression=OR(ROW(INDIRECT(YEAR($B3)*100+MONTH($B3)&":"&YEAR($C3)*100+MONTH($C3)))=YEAR(D$1)*100+MONTH(D$1),ROW(INDIRECT(YEAR($B3)*100+MONTH($B3)&":"&YEAR($C3)*100+MONTH($C3)))=YEAR(D$1+45)*100+MONTH(D$1+45),ROW(INDIRECT(YEAR($B3)*100+MONTH($B3)&":"&YEAR($C3)*100+MONTH($C3)))=YEAR(D$1+70)*100+MONTH(D$1+70))textNO
 
Upvote 0
Another option without helper cells
+Fluff 1.xlsm
ABCDEFGHIJK
1baseline startbaseline end2021 Q12021 Q22021 Q32021 Q42022 Q12022 Q22022 Q32022 Q4
2apple25/02/202130/12/2021
3orange30/04/202130/05/2022
Main
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D2:K3Expression=AND($B2<=DATE(LEFT(D$1,4),RIGHT(D$1)*3,1),$C2>=DATE(LEFT(D$1,4),RIGHT(D$1)*3-2,1))textNO
 
Upvote 0
THANK YOU FLUFF and JamesCanale!! You saved me hours of banging my head on a wall!!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,930
Members
449,094
Latest member
teemeren

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