Skip to main content

Highlighting Duplicates except First Occurrence.

This post is in continuation to First one i.e. Restricting User to enter Duplicate Values using Data Validation. As the previous Duplicate Restrictor has some limitations. So I came up with a rather new way ( Conditional Formatting ) to achieve it.This time, it will highlight the duplicate cell, that is too, except First Occurrence.


Here is the Conditional Formatting formula:-
=COUNTIF($C$1:$C1,$C1)>1 

Here are the steps:-
1. Select the Target Column say C ( in the attached example )
2. Go to Home Tab--> Conditional Formatting ---> New Rule --> Formula
3. Type the above formula there.
4. Select the formatting for highlighting the duplicates found like filing colour in cell or colouring Font.
    ( I have used Green Colour in the attached example )
5.  Click OK.

Explanation:-
The Target column which has been selected, is the Range on which Conditional formatting applies. Excel interprates above formula in context of Each cell in the Target Range and decides whether that cell has Unique or Duplicate entry. The $C1 parameter of Countif formula is a Row relative range. So when excel moves to next cell downwards in the Target Range, $C1 changes to $C2 and so on, for each next cell. When user puts a duplicate in the cell and hit enter, excel immediately interprates above formula in regard of that cell (by changing $C1 accordingly) and highlights the cell as count of that cell value in the whole C column will become 2 which is more than 1. So condition >1 will get True and excel will Highlight the cell in context. This is how it works.


Check the attached example file:-

Comments

Popular posts from this blog

Automation:- Sending Invitation to Meeting Using Excel VBA

Hello Everyone, In one of the previous post, I wrote about automating Sending Emails using Excel VBA. This time I have come up with a pretty similar code. The code below sends Outlook Meeting Invitations to recipients on one click. here is the Code:- Sub Send_Invite_Auto() Dim olApp As Outlook.Application Dim olApt As AppointmentItem Set olApp = New Outlook.Application 'Creating Outlook Session Set olApt = olApp.CreateItem(olAppointmentItem) 'Creating an Appointment With olApt .Subject = "Enter the subject here." 'Subject .Start = DateAdd("d", 5, Now) 'Enter Date + Time here. .Recipients.Add ("example@gmail.com") 'Recipient Name, Alias, or any other Attribute. .MeetingStatus = olMeeting 'olAppointmentItem with Meeting status olMeeting 'becom...

Making Password Protected PDFs using Excel Vba and PDFtk Tool

Hi Everyone, This time, I have come up a VBA Code to generate Password protected PDFs using Excel. Actually, Excel Vba has .ExportAsFixedFormat Method to generate PDFs but this hasn't any Parameter which takes password to protect the PDFs. So I have used PDFtk Tool which provide Command Line Interface to make PDFs protected using Password. Actually, You can do various things using PDFtk Tool command line varying from creating, merging, Protecting and many other. So Download the PDFtk Tool from the following link:- Download PDFtk Tookit Here are the Steps:- 1. Install the PDFtk Toolkit. 2. Use the following code to Print or Export the Activesheet with a password.

Highlighting Duplicates across multiple sheets

Hi One and All, This time I have come up with some conditional formatting stuff. The aim is to highlight the duplicates across multiple sheets and with in the sheet as well. Assumptions:- 1. I am assuming that sheet names goes on like sheet1, sheet2, sheet3.... 2. The Target Column No. is same in all the sheets. I mean, as in the attached example, its Column A which is being targeted in both sheets.