Conditional Format Date Range

zero269

Board Regular
Joined
Jan 16, 2023
Messages
219
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm having some trouble figuring out how to properly Conditionally Format a single date that falls on or within a Start Date and End Date from two separate columns. In the Mini Sheet below, it's only highlighting the dates that fall on a single date, but not within a range.

In the data set below, I should see both 29-Sep and 2-Oct highlighted along with the last two representing Christmas Eve and Christmas Day. Only Columbus Day is being highlighted which is not a range. I'm currently using a single column in my main workbook, but I'm trying to use the following range option to avoid a lengthy single column list for large date ranges.

I created Named Ranges for the Start and End dates in order to use them with CF.

Any help would be greatly appreciated...

Here's a brief sample set of data that I'm working with:

VBA Testing.xlsm
BCDEFGH
1d-mmmtestHolidayStart DateEnd DateHoliday
228-Sep02023-01-012023-01-01New Year's Day
329-Sep0Random Holiday Range2023-01-162023-01-16MLK Jr. Day
42-Oct0Random Holiday Range2023-02-202023-02-20President's Day
53-Oct02023-04-092023-04-09Easter Sunday
64-Oct02023-05-292023-05-29Memorial Day
75-Oct02023-07-042023-07-04Independence Day
86-Oct02023-09-042023-09-04Labor Day
99-Oct1Columbus Day2023-10-092023-10-09Columbus Day
1010-Oct02023-11-112023-11-11Veteran's Day
1111-Oct02023-11-222023-11-23Thanksgiving break
1224-Dec0Christmas break2023-12-242023-12-25Christmas break
1325-Dec0Christmas break2023-09-292023-10-02Random Holiday Range
CF Dates
Cell Formulas
RangeFormula
F2:G2F2=DATE(YEAR(TODAY()),1,1)
F3:G3F3=DATE(YEAR(TODAY()),1,1)+14+CHOOSE(WEEKDAY(DATE(YEAR(TODAY()),1,1)),1,0,6,5,4,3,2)
F4:G4F4=DATE(YEAR(TODAY()),2,1)+14+CHOOSE(WEEKDAY(DATE(YEAR(TODAY()),2,1)),1,0,6,5,4,3,2)
F5:G5F5= ROUND(DATE(YEAR(TODAY()),4,MOD(234-11*MOD(YEAR(TODAY()),19),30))/7,0)* 7-6
F6:G6F6=DATE(YEAR(TODAY()),5,31)-CHOOSE(WEEKDAY(DATE(YEAR(TODAY()),5,31)),6,0,1,2,3,4,5)
F7:G7F7=DATE(YEAR(TODAY()),7,4)
F8:G8F8=DATE(YEAR(TODAY()),9,1)+CHOOSE(WEEKDAY(DATE(YEAR(TODAY()),9,1)),1,0,6,5,4,3,2)
F9:G9F9=DATE(YEAR(TODAY()),10,1)+7+CHOOSE(WEEKDAY(DATE(YEAR(TODAY()),10,1)),1,0,6,5,4,3,2)
F10:G10F10=DATE(YEAR(TODAY()),11,11)
F11F11=DATE(YEAR(TODAY()),11,1)+21+CHOOSE(WEEKDAY(DATE(YEAR(TODAY()),11,1)),4,3,2,1,0,6,5)-1
G11G11=DATE(YEAR(TODAY()),11,1)+21+CHOOSE(WEEKDAY(DATE(YEAR(TODAY()),11,1)),4,3,2,1,0,6,5)
F12F12=DATE(YEAR(TODAY()),12,25)-1
G12G12=DATE(YEAR(TODAY()),12,25)
B3:B11,B13B3=WORKDAY($B2,1)
C2:C13C2=COUNTIFS(lstStartDate,">="&$B2,lstEndDate,"<="&$B2)
Named Ranges
NameRefers ToCells
lstEndDate='CF Dates'!$G$2:$G$13C2:C13
lstStartDate='CF Dates'!$F$2:$F$13C2:C13
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B13Expression=COUNTIFS(lstStartDate,">="&$B2,lstEndDate,"<="&$B2)textNO
F2:F12Cell ValueduplicatestextNO
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
within a Start Date and End Date from two separate columns
Rather than making a start date and end date, make a single column of holidays and then apply conditional formatting. That would be easier and less complicated.
 
Upvote 1
Change to:

=COUNTIFS(lstStartDate,"<="&$B2,lstEndDate,">="&$B2)
 
Upvote 1
Solution
Change to:

=COUNTIFS(lstStartDate,"<="&$B2,lstEndDate,">="&$B2)
Thanks Phuoc, that did the trick perfectly. I can't believe I had them reversed.

I played around with the dates to see more results and it's highlighting everything that should be.

1693596381946.png
 
Upvote 0
Rather than making a start date and end date, make a single column of holidays and then apply conditional formatting. That would be easier and less complicated.
Hi Sanjay,

Thanks for the feedback, but unfortunately that's what I'm trying to avoid. I have some date ranges - not shown - that span several weeks. It's far too cumbersome to mange date ranges in a single column.

I'm currently using a single column in my main workbook, but I'm trying to use the following range option to avoid a lengthy single column list for large date ranges.
 
Upvote 0

Forum statistics

Threads
1,215,072
Messages
6,122,966
Members
449,094
Latest member
Anshu121

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