Removing Duplicates in Excel
Amber MacArthur, Bill Jelen, Leo LaPorte, Andy Walker on the set of Call for Help on TechTV Canada. The tip in this show is from Excel for Auditors.
In today's episode, I compared how to find or remove duplicates. Excel 2007 offers cool new ways to do this. The first 3 tips work in any version of Excel. The last 2 methods work only in Excel 2007. Method 1: Use the Unique Option in Advanced Filter
Method 2: Use a Formula to Determine if This Record is Unique
The COUNTIF function can count how many records above the current record match the current record. The trick to making this work is to use a single dollar sign in the reference. If you are entering a formula in C2 and you reference A$1:A1, this is saying, "Start from the absolute reference of A1 and go down to the record above the current record". When you copy this formula down, the first A$1 will stay the same. The second A1 will change. In Row 17, the formula in C2 will read: =COUNTIF(A$1:A16,A17)=0.
Once you have entered the formula in C2 and copied it down to all rows, you should copy C2:C15 and then use Edit - Paste Special Values to convert the formulas to values. You can now sort descending by column C and the unique values will be at the top of the list. Method 3: Use a Pivot Table to get Unique Customers
A pivot table is great at finding unique values. This is the fastest way in Excel 2000-2003.
Method 4: New in Excel 2007 - Use Conditional Formatting to Mark Duplicates
Excel 2007 offers new methods for finding duplicates. Select the range of customers. From the Home ribbon, choose Conditional Formatting - Highlight Cells Rules - Duplicate Values and click OK.
If a name is found twice, Excel will highlight both occurences of the name. You would then want to sort all of the highlighted cells to the top.
This method is highly destructive! Make a copy of your dataset before you do this!
As you can see, there are many methods for dealing with duplicates. Excel 2007 adds two new tools to your arsenal. In my experience, auditors are frequently trying to locate duplicates to detect if a report has been overstated. When I wrote Excel for Auditors, I cover both Excel 2003 and Excel 2007. For the BEST TV show on technology, check out Call for Help. This tip was originally published on December 26, 2006 and aired on TechTV in Canada and Australia on December 27, 2006. The permanent URL for this page is http://www.mrexcel.com/tip138.shtml. If you are looking for show notes from another episode, visit my complete list of TechTV appearances.
MrExcel.com provides examples of Visual Basic procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures on this web site are provided "as is" and we do not guarantee that they can be used in all situations.
Excel is a registered trademark
of the Microsoft® Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.
All contents Copyright 1998-2008 by MrExcel Consulting.