Please Note: This article is written for users of the following Microsoft Excel versions: 2007 and 2010. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Checking for Duplicate Rows Based on a Range of Columns.
by Allen Wyatt
(last updated January 4, 2018)
Jennifer has a lot of data in a worksheet, and she considers some of the rows to be duplicates. She determines whether a row is a duplicate based upon whether a range of columns in one row is identical to the same range of columns in the previous row. For instance, if all of the values in F7:AB7 are identical to the values in F6:AB6, the Jennifer would consider row 7 to be a duplicate of row 6. She wonders if there is a way that she can easily check for such duplicate rows and highlight the duplicates in some manner.
One approach to this problem is to utilize the conditional formatting capabilities of Excel. If your data is in rows A1:AZ100, then select the range You could then use the following as a formulaic test within your conditional format:
If your conditional format applies a color to the cells, then you'll see the color appear anytime the values in columns F through AB are equal to the values in the same columns of the row directly above the one that is colored.
If Jennifer's data consists only of cells in the columns F:AB, then she can use the filtering capabilities of Excel to mark the duplicate rows. Here are the general steps:
Figure 1. The Advanced Filter dialog box.
At this point, only the duplicate records are highlighted with the color you used in step 2. These records can be safely deleted, leaving only the unique records.
Perhaps an even easier approach is to allow Excel to determine the duplicates and remove the rows. Follow these steps:
Figure 2. The Remove Duplicates dialog box.
The powerful feature of using the Remove Duplicates tool is that the order of the records in the table don't really matter. In other words, the tool doesn't just compare the specified columns in one row to the row above it—it compares the specified columns in one row to all the other rows and it keeps only those that are unique.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10608) applies to Microsoft Excel 2007 and 2010. You can find a version of this tip for the older menu interface of Excel here: Checking for Duplicate Rows Based on a Range of Columns.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
When you add a named range to a worksheet, you can specify if you want that named range to apply to the workbook or only ...Discover More
Operators are used in formulas to instruct Excel what to do to arrive at a result. Not all operators are evaluated in the ...Discover More
Addresses used in a formula can be either relative or absolute. If you need to switch between the two types of ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.