Highlight duplicates with same date, week or month
The image above demonstrates a conditional formatting formula that highlights duplicate items based on date. The first instance is not highlighted, only subsequent duplicates are highlighted.
Conditional formatting formula:
Explaining Conditional formatting formula
Step 1 - Concatenate cell values
The cell references $C3 and $D3 are locked to each column, however, they change when CF move to the next row. The ampersand sign concatenates the values in these cells.
$C3&"-"&$D3
becomes
40184&"-"&1150
and returns
"40184-1150"
Step 2 - Concatenate values using expanding cell references
These cell references expand as the CF moves to cells below, the formula keeps track of previous values so it can detect duplicate values.
$C3:$C$3&"-"&$D3:$D$3
becomes
40184&"-"&1150
and returns
"40184-1150".
Step 3 - Compare concatenated values
The equal sign lets you compare values, the result is always TRUE or FALSE.
$C3&"-"&$D3=$C3:$C$3&"-"&$D3:$D$3
becomes
"40184-1150" = "40184-1150"
and returns TRUE.
Step 4 - Convert boolean values
The SUMPRODUCT function can't work with boolean values, we must convert it (them) to their numerical equivalents. TRUE = 1 and FALSE equals 0 (zero).
--($C3&"-"&$D3=$C3:$C$3&"-"&$D3:$D$3)
becomes
--(TRUE)
and returns 1.
Step 5 - Sum values
The SUMPRODUCT function sums the values in the array in this step.
SUMPRODUCT(--($C3&"-"&$D3=$C3:$C$3&"-"&$D3:$D$3))
becomes
SUMPRODUCT(1)
and returns 1.
Step 6 - Check if duplicate
This steps checks if the sum is larger than 1, if it is then TRUE is returned and the cell is highlighted.
SUMPRODUCT(--($C3&"-"&$D3=$C3:$C$3&"-"&$D3:$D$3))>1
becomes
1>1
and returns FALSE. Cell C3 is not highlighted.
Get Excel *.xlsx file
Highlight-duplicates-within-same-date-week-month-year.xlsx
Highlight duplicates on same week
Conditional formatting formula:
Highlight duplicates on same month
Conditional formatting formula:
Get excel sample file for this article.
Highlight-duplicates-within-same-date-week-month-year.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
YEAR(serial_number) returns the year of a date, an integer of the range 1900-9999
MONTH(serial_number) returns the month, a number from 1 (January) to 12 (December)
WEEKNUM(serial_number, return_type)
Returns the week number in the year
Recommended reading
Built-in conditional formatting
Data Bars Color scales IconsHighlight cells rule
Highlight cells containing stringHighlight a date occuring
Conditional Formatting Basics
Highlight unique/duplicates
Top bottom rules
Highlight top 10 valuesHighlight top 10 % values
Highlight above average values
Basic CF formulas
Working with Conditional Formatting formulasFind numbers in close proximity to a given number
Highlight empty cells
Highlight text values
Search using CF
Highlight records – multiple criteria [OR logic]Highlight records [AND logic]
Highlight records containing text strings (AND Logic)
Highlight lookup values
Unique distinct
How to highlight unique distinct valuesHighlight unique values and unique distinct values in a cell range
Highlight unique values in a filtered Excel table
Highlight unique distinct records
Duplicates
How to highlight duplicate valuesHighlight duplicates in two columns
Highlight duplicate values in a cell range
Highlight smallest duplicate number
Highlight more than once taken course in any given day
Highlight duplicates with same date, week or month
Highlight duplicate records
Highlight duplicate columns
Highlight duplicates in a filtered Excel Table
Compare
Highlight missing values between to columnsCompare two columns and highlight values in common
Compare two lists of data: Highlight common records
Compare tables: Highlight records not in both tables
How to highlight differences and common values in lists
Compare two columns and highlight differences
Min max
Highlight smallest duplicate numberHow to highlight MAX and MIN value based on month
Highlight closest number
Dates
Advanced Date Highlighting Techniques in ExcelHow to highlight MAX and MIN value based on month
Highlight odd/even months
Highlight overlapping date ranges using conditional formatting
Highlight records based on overlapping date ranges and a condition
Highlight date ranges overlapping selected record [VBA]
How to highlight weekends [Conditional Formatting]
How to highlight dates based on day of week
Highlight current date
Misc
Highlight every other rowDynamic formatting
Miscellaneous conditional formatting techniques
Highlight cells based on ranges
Highlight opposite numbers
Highlight cells based on coordinates
Excel categories
4 Responses to “Highlight duplicates with same date, week or month”
Leave a Reply
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
HI
I need to learn excel both the basic and the advance level specifically through online which includes both audio and video.
Im working in a Corporate and feel excel will enhance my skills.
Can you contact me through my emial and let me know the feasibility and convenience.
Thanks
Nirmala
Nirmala,
I have sent you an email.
/Oscar
Hi,
I'm trying to find a way to highlight cells with text/number (column B) if reoccurred 3 times or more within the last 3 days (dates in column A)
I hope someone can help
Hello,
I'm doing this for a spreadsheet where I don't want a blank cell (in the second column) to match with another blank cell. How can I modify the formula accordingly? For instance, in my work I drag down the dates in column A before entering the rest of the data. I'm looking for a match between column A&E between rows. But at the moment it does this, but also highlights all the prepped rows at the end where I've dragged down the date. I want it not to consider the same date in A and a blank in E to be a match with another same date A and blank E.
Thanks!