Highlight overlapping date ranges using conditional formatting in excel


How to highlight overlapping date ranges (Excel 2007)
- Click "Home" tab
- Click "Conditional Formatting" button
- Click "New Rule.."
- Click "Use a formula to determine which cells to format"
- Type =SUMPRODUCT(($C6<=$D$6:$D$12)*($D6>=$C$6:$C$12))>1 in "Format values where this formula is TRUE" window.
- Click "Format.." button
- Click "Fill" tab
- Select a color for highlighting cells.
- Click "Ok"
- Click "Ok"
- Click "Ok"
Explaining conditional formatting formula
=SUMPRODUCT(($C6<=$D$6:$D$12)*($D6>=$C$6:$C$12))>1
Step 1 - Filter records where ($C6<=$D$6:$D$12) is TRUE
$C6<=$D$6:$D$12 returns an array of TRUE and/or FALSE if date in cell C6 is smaller or equal to each date in $D$6:$D$12.
All dates in$D$6:$D$12 are larger than $C6 so the returning array is (TRUE, TRUE, TRUE,TRUE, TRUE, TRUE,TRUE)
Step 2 - Filter records where ($D6>=$C$6:$C$12) is TRUE
($D6>=$C$6:$C$12) returns an array of TRUE and/or FALSE if date in cell D6 is bigger or equal to each date in $C$6:$C$12.
The returning array is (TRUE, FALSE, FALSE,TRUE, FALSE, FALSE,FALSE)
Step 3 - Putting it all together
($C6<=$D$6:$D$12)* ($D6>=$C$6:$C$12)) returns the following array (1,0,0,1,0,0,0).
That means array number one and four is overlapping C6:D6) but in this case we just want to know if any date range is overlapping.
=SUMPRODUCT(($C6<=$D$6:$D$12)*($D6>=$C$6:$C$12)) sums the array (1,0,0,1,0,0,0) and returns 2.
If the formula returns a number bigger than one there is at least one overlapping date range.
=SUMPRODUCT(($C6<=$D$6:$D$12)*($D6>=$C$6:$C$12))>1 returns TRUE or FALSE.
Download excel sample file for this tutorial.
highlight overlapping dates.xls
(Excel 97-2003 Workbook *.xls)
Functions in this article:
SUMPRODUCT(array1, array2, )
Returns the sum of the products of the corresponding ranges or arrays
Related blog posts
- Highlight duplicate values and overlapping dates in excel
- Find overlapping date ranges in excel
- Filter overlapping dates from date ranges in excel
- Highlight dates within a date range using conditional formatting
- Highlight duplicates where an adjacent column is in a date interval using conditional formatting in excel







October 8th, 2010 at 12:45 am
Hi, I have a situation where I want to count if this value is duplicate and if it the dates are overlapping as well. Is there anyway to work this out?
eg
Serial | Start date | End Date
ABC | 01.01.2009 | 31.12.2009
BCD | 01.06.2009 | 31.12.2009
ABC | 01.07.2009 | 30.06.2010
So it should list the first and third entry.
October 9th, 2010 at 8:15 am
[...] Highlight duplicate values and overlapping dates in excel Filed in Excel on Oct.09, 2010. Email This article to a Friend adam asks: [...]
October 10th, 2010 at 10:05 pm
Adam,
read this post: Highlight duplicate values and overlapping dates in excel
April 19th, 2011 at 3:10 pm
I want to do something similar but only if the value in column B is the same as the previous or subseqhent row. In other words, column B might be something like an employee number (5 in this case) and I only want to look for overlapping dates across the same employee number like this.
# Start date End date
5 2/11/1995 10/22/2002
5 10/22/2002 12/31/9999
The above overlap as does the below
5 2/11/1995 10/22/2002
5 10/19/2002 12/31/9999
Can I do this in excel with the condition that the employee number Key (5 in this case) has to match?
April 20th, 2011 at 8:53 am
PJ,
Conditional formatting formula:
=SUMPRODUCT(($C6< =$D$6:$D$12)*($D6>=$C$6:$C$12)*($B6=$B$6:$B$12))>1
Download excel file