Friday, April 25, 2014

Highlight unique values in a filtered excel table

Conditional Formatting has some amazing built-in features, for example it lets you highlight unique values in a list without entering a CF formula. If you don´t know how to do this, follow these instructions:
  1. Select your list
  2. Go to "Home" tab on the ribbon.
  3. Click Conditional formatting button
  4. Hover over "Highlight Cells Rules"
  5. Click "Duplicate values..."
  6. Change to "Unique"
    Format cells that contain unique values
  7. Click OK
However, if you then decide to filter the list, the CF rule still highlights unique values as if it is not filtered. The following CF formula highlights unique values in a filtered list.
=SUM(COUNTIF(INDIRECT("Table1[@Description]"), IF(SUBTOTAL(3, OFFSET(INDIRECT("Table1[Description]"), MATCH(ROW(INDIRECT("Table1[Description]")), ROW(INDIRECT("Table1[Description]")))-1,  0, 1)), INDIRECT("Table1[Description]"), "")))=1
You can see in the animated gif below that in the entire list Matsumura Fishworks and QWERTY logistics have duplicate values but in the filtered list Matsumura Fishworks is a unique value and therefor highlighted. That would not be the case if you had used the built-in CF feature.
Highlight unique values in a filtered table5

 How to apply a CF formula rule
You probably use another table name on our worksheet, so make sure you change the name in the CF formula.
  1. Select the table column or list
  2. Go to "Home" tab on the ribbon
  3. Click Conditional formatting button
  4. Click "New rule..."
  5. Click "Use a formula to determine which cells to format"
  6. Paste the above formula in this field.
    format values where this formula is true
  7. Click "Format..." button
  8. Go to tab "Fill"
  9. Pick a background color
  10. Click OK button twice

No comments:

Post a Comment