Locked lesson.
About this lesson
Create a new conditional formatting rule using a formula that highlights the row if a duplicate is found.
Exercise files
Download this lesson’s related exercise files.
04-04-Highlight Duplicate Rows in a List-Start.xlsx2.4 MB 04-04-Highlight Duplicate Rows in a List-Complete.xlsx
2.1 MB Exercise - Highlight Rows with Conditional Formatting.xlsx
11.1 KB 4.04 highlight-rows-with-data-validation-and-formatting - Exercise.docx
43.3 KB Exercise Solution - Highlight Rows with Conditional Formatting.xlsx
12.3 KB 4.04 highlight-rows-with-data-validation-and-formatting - Exercise solution.docx
187.1 KB
Quick reference
Highlight Rows in a List with Conditional Formatting and Data Validation
Use Conditional Formatting and Data Validation to highlight duplicate rows in a dataset.
When to use
This technique is useful when we want to make a selection in a data validation drop-down list and have it highlight all matches in a table.
Instructions
In this example, we want to select a pizza name from a drop-down list and highlight all orders that match the pizza name in the table below.
We are going to do this using a combination of data validation and conditional formatting with formulas.
Format as an Excel Table
To ensure our formulas are dynamic and update when new data is added, we need to format our data as an Excel table.
- Click anywhere in the dataset.
- Press CTRL+T.
- Ensure My table has headers is selected.
- Click OK.
- From the Table Design tab, in the Properties group, name the table 'PizzaOrders'.
Extract a Unique List
Next, we need to extract a unique list of the pizza names from the orders table.
- Click in an empty cell in the worksheet.
- Type =UNQUE(PizzaOrders[Pizza Name])
Create a Data Validation List
Now that we have a unique list of values, we can use them to create our data validation drop-down list.
- Click in cell C6.
- From the Data tab, in the Data Tools group, click Data Validation.
- Click the drop-down arrow in the Allow section and choose List.
- Click in Source.
- Select the first cell of the unique list and add the # symbol.
- Click OK.
Setup a Conditional Formatting Rule
Now we need to add some functionality so that when a pizza is selected from the list, all orders that match the pizza name are highlighted in the orders table.
- Click in the 'PizzaOrders' table and press CTRL+A to select all.
- From the Home tab, in the Styles group, click Conditional Formatting.
- Click New Rule.
- From Select a Rule Type, choose Use a formula to determine which cells to format.
Our formula needs to look in column C for the pizza name that's been selected in cell C6 and if it finds a match, apply cell formatting.
By default, Excel will apply absolute referencing to cell C11. If we were to leave it like this, the cell formatting would only apply to cell C11.
- Press F4 twice to lock the column but not the row.
We are checking if the pizza name in column C matches the pizza name in cell C6.
- Click Format.
- Choose how to format the cells.
- Click OK.
Hints & tips
- If you are using a version of Excel that doesn't have the UNIQUE function, you can copy and paste the pizza names and then use the Remove Duplicates tool (Data > Remove Duplicates) to achieve the same result.
- To hide the list of unique values, select the column, right-click, and choose Hide from the menu.
Lesson notes are only available for subscribers.