Filter for unique values or remove duplicate values

In Microsoft Office Excel 2007, you have several ways to filter for unique values or remove duplicate values:

  • To filter for unique values, use the Advanced command in the Sort & Filter group on the Data tab.
  • To remove duplicate values, use the Remove Duplicates command in the Data Tools group on the Data tab.
  • To highlight unique or duplicate values, use the Conditional Formatting command in the Style group on the Home tab.
What do you want to do?


Learn about filtering for unique values or removing duplicate values

Filtering for unique values and removing duplicate values are two closely related tasks because the displayed results are the same — a list of unique values. The difference, however, is important: When you filter for unique values, you temporarily hide duplicate values, but when you remove duplicate values, you permanently delete duplicate values.

A duplicate value is one where all values in the row are an exact match of all the values in another row. Duplicate values are determined by the value displayed in the cell and not necessarily the value stored in the cell. For example, if you have the same date value in different cells, one formatted as "3/8/2006" and the other as "Mar 8, 2006", the values are unique.

It's a good idea to filter for or conditionally format unique values first to confirm that the results are what you want before removing duplicate values.

Top of Page Top of Page

Filter for unique values

  1. Select the range of cells, or make sure the active cell is in a table.
  2. On the Data tab, in the Sort & Filter group, click Advanced.

Outlook Ribbon Image

  1. In the Advanced Filter dialog box, do one of the following:
    1. To filter the range of cells or table in place, click Filter the list, in-place.
    2. To copy the results of the filter to another location, do the following:
      1. Click Copy to another location.
      2. In the Copy to box, enter a cell reference.

Alternatively, click Collapse Dialog Button image to temporarily hide the dialog box, select a cell on the worksheet, and then press Expand Dialog Button image.

  1. Select the Unique records only check box, and click OK.

The unique values from the selected range are copied to the new location.

Top of Page Top of Page

Remove duplicate values

When you remove duplicate values, only the values in the range of cells or table are affected. Any other values outside the range of cells or table are not altered or moved.

Because you are permanently deleting data, it's a good idea to copy the original range of cells or table to another worksheet or workbook before removing duplicate values.

  1. Select the range of cells, or make sure that the active cell is in a table.
  2. On the Data tab, in the Data Tools group, click Remove Duplicates.

Excel Ribbon Image

  1. Do one or more of the following:
    • Under Columns, select one or more columns.
    • To quickly select all columns, click Select All.
    • To quickly clear all columns, click Unselect All.

If the range of cells or table contains many columns and you want to only select a few columns, you may find it easier to click Unselect All, and then under Columns, select those columns.

  1. Click OK.

A message is displayed indicating how many duplicate values were removed and how many unique values remain, or if no duplicate values were removed.

  1. Click OK.

ShowIssue: I'm having problems removing duplicate values from data that is outlined or that has subtotals.

You cannot remove duplicate values from data that is outlined or that has subtotals. To remove duplicates, you must remove both the outline and the subtotals. For more information, see Outline a list of data in a worksheet and Remove subtotals.

Top of Page Top of Page

Conditionally format unique or duplicate values

 Note   You cannot conditionally format fields in the Values area of a PivotTable report by unique or duplicate values.

Quick formatting

  1. Select one or more cells in a range, table, or PivotTable report.
  2. On the Home tab, in the Style group, click the arrow next to Conditional Formatting, and then click Highlight Cells Rules.

Outlook Ribbon Image

  1. Select Duplicate Values.
  2. Enter the values that you want to use, and then select a format.

Advanced formatting

  1. Select one or more cells in a range, table, or PivotTable report.
  2. On the Home tab, in the Styles group, click the arrow next to Conditional Formatting, and then click Manage Rules.

The Conditional Formatting Rules Manager dialog box is displayed.

  1. Do one of the following:
    • To add a conditional format, click New Rule.

The New Formatting Rule dialog box is displayed.

  • To change a conditional format, do the following:
    1. Make sure that the appropriate worksheet or table is selected in the Show formatting rules for list box.
    2. Optionally, change the range of cells by clicking Collapse Dialog Button image in the Applies to box to temporarily hide the dialog box, by selecting the new range of cells on the worksheet, and then by selecting Expand Dialog Button image.
    3. Select the rule, and then click Edit rule.

The Edit Formatting Rule dialog box is displayed.

  1. Under Select a Rule Type, click Format only unique or duplicate values.
  2. Under Edit the Rule Description, in the Format all list box, select unique or duplicate.
  3. Click Format to display the Format Cells dialog box.
  4. Select the number, font, border, or fill format that you want to apply when the cell value meets the condition, and then click OK.

You can choose more than one format. The formats that you select are displayed in the Preview box.

Top of Page Top of Page

 
 
Applies to:
Excel 2007