A quick trick for hiding duplicate Excel values

Duplicate values aren't wrong, but you might not want to display them. Use this simple technique to hide duplicate values in Excel.

Duplicate values aren't wrong or bad, but they can be distracting. You probably won't want to delete them, but you might just want to hide them. For example, the simple sheet below repeats date values in column A. In a reporting scenario, those duplicate dates might be annoying.

The easiest way to hide them is to apply a conditional format that changes the font color to the same as the cell's background. The data's still there, but you won't see it. This technique is easy to implement, as promised, but it comes with inherent risks because users forget what they can't see. A sheet with hidden details can be difficult to maintain and troubleshoot. Keep that in mind when you decide whether this technique is right for you.

A quick detour

You might be tempted to use one of Excel's built-in conditional format rules (not available in 2003), but it won't work as expected. It'll hide each instance of a duplicate value. It won't leave the first occurring instance and hide the rest - and that's what we're after. Now, let's take a quick look at what happens when you apply the duplicates rule:

  1. Select A2:A13.
  2. Click the Conditional Formatting option in the Styles group.
  3. Choose Highlight Cells Rule.
  4. Select Duplicate Values.
  5. From the Format dropdown choose Custom Format.
  6. In the resulting dialog, click the Font tab if necessary. Then, choose white (or the color that matches the cell background).
  7. Click OK twice.

The format doesn't produce the results you want - it hides every instance of each duplicate value.

A hiding conditional format

Now let's look at a conditional format that works as expected. First, sort the recordset by the column you're going to format. We'll be using a formula rule that compares two adjacent values - so the values must be sorted for this technique to work. The built-in rule we just reviewed doesn't require a sorted list.

After sorting, hide the duplicate values, as follows:

  1. Select A2:A13.
  2. Click the Conditional Formatting option in the Styles group, and choose New Group. In Excel 2003, choose Conditional Formatting from the Format menu.
  3. Choose Use A Formula To Determine Which Cells To Format from the Select A Rule Type list.
  4. In the lower pane, enter the following formula: =A1=A2
  5. Click Format.
  6. In the resulting dialog, click the Font tab if necessary.
  7. Choose white from the Color palette (or the color that matches the cell background).
  8. Click OK twice.

You probably noticed that the formula refers to a header cell (A1) and not the first cell in the selected range (the data range). This offset tricks the format into formatting subsequent duplicates. If you refer to the first and second cells in the selected range (=A2=A3), the rule would hide all but the last duplicate value.


To reiterate, this technique might create difficulties down the road. There's nothing wrong with the technique, but the hidden data can be easy to forget. In this particular case, the risk seems inconsequential; it won't always be so. For more on unforeseen formatting headaches, read 10 Excel formatting decisions that can have unfortunate repercussions.

Sample Excel worksheets of this technique are available.


Susan Sales Harkins is an IT consultant, specializing in desktop solutions. Previously, she was editor in chief for The Cobb Group, the world's largest publisher of technical journals.

Editor's Picks