Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Checking for Duplicate Rows Based on a Range of Columns.

Checking for Duplicate Rows Based on a Range of Columns

Written by Allen Wyatt (last updated September 29, 2018)
This tip applies to Excel 97, 2000, 2002, and 2003


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(AND($F2:$AB2=$F1:$AB1),1,0)=1

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:

  1. Select the cells containing your data. For instance, if the first row contains column headers, you should select F2:AB100.
  2. Apply a color to those cells, so that all the data is shaded some unique color.
  3. Select any cell in data table.
  4. Choose Filter from the Data menu, then choose Advanced Filter from the resulting submenu. Excel displays the Advanced Filter dialog box. (See Figure 1.)
  5. Figure 1. The Advanced Filter dialog box.

  6. Make sure that Filter the List, In Place is selected. (It should be selected by default.)
  7. Click the Unique Records Only check box.
  8. Click OK. Excel collapses your data so that only unique (non-duplicate) records are shown.
  9. Select the visible rows of data.
  10. Remove the color you applied in step 2.
  11. Remove the filter you applied in steps 4 through 7.

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.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10607) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Checking for Duplicate Rows Based on a Range of Columns.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Wiping a Drive

Want to easily improve the security of your old data? Here's an addition to the venerable format command that can help.

Discover More

Removing Personal Information

As you create and work on your workbooks, Excel can include sensitive personal information with the data. If you want to ...

Discover More

Ordering Worksheets Based on a Cell Value

Need to sort your worksheets so that they appear in an order determined by the value of a cell on each worksheet? Using a ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (menu)

Removing Duplicate Rows

Too much data in your worksheet? Does too much of that data duplicate other data? Here's how to get rid of the duplicates ...

Discover More

Conditionally Deleting Rows

Want to delete a bunch of rows in a worksheet based on the value in a certain cell of each row? There are a couple of ...

Discover More

Quickly Deleting Cells

If you need to delete a cell, the Delete key won't do it. (That only clears the contents of a cell; it doesn't delete the ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 4 - 1?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.