## Compare two lists of data: Highlight common records

In this blog post I will demonstrate a conditional formatting formula that will highlight common records in two lists. The image above shows you highlighted records in List 1 that also exists in sheet2.

You can also use a formula to extract shared records or an Excel defined table, if you prefer that. There is also an article written for Comparing two columns and highlight values in common.

There are more links to related articles in the sidebar.

### Create named ranges

When constructing a conditional formatting formula you can only reference cells on current sheet. But there is a workaround. The answer is named ranges.

Here is how to create named ranges for this example:

- Go to sheet List 2
- Select cell range A2:A13
- Click in Name box
- Type a name (Year)
- Repeat step 1 to 4 with remaining columns.

### Setup COUNTIFS function

The COUNTIFS function looks for duplicate records in the second list (List 2).

**COUNTIFS(**criteria_range1,criteria1, criteria_range2, criteria2...**)**

Counts the number of cells specified by a given set of conditions or criteria

In this example:

List 1:Column A - List 2: Column A (Year)

List 1:Column B - List 2: Column B (Asset)

List 1:Column C - List 2: Column C (Cost)

COUNTIFS(YEAR, $A2, ASSET, $B2, COST, $C2)

This formula contains absolute and relative cell references. The conditional formatting formula must look for values in matching columns.

$A2 is a cell reference to values in column A. The column ($A) is absolute but the row (2) is relative. When the conditional formatting formula executes the next row, only the row number changes, example $A3. The named ranges do not change.

If the COUNTIFS function finds one matching record it returns 1, if nothing is found 0 (zero) is returned. 0 (zero) is the equivalent to FALSE so the Conditional formatting will not highlight a cell i FALSE is returned.

### Highlight common records from two lists Excel 2007

How to apply conditional formatting formula:

- Select cells A2:C11 (Sheet: List 1)
- Click "Home" tab
- Click "Conditional Formatting" button
- Click "New Rule.."
- Click "Use a formula to determine which cells to format"
- Type =COUNTIFS(YEAR, $A2, ASSET, $B2, COST, $C2) in "Format values where this formula is TRUE" window.

(The formula shown in the image above is not used in this article) - Click "Format.." button
- Click "Fill" tab
- Select a color for highlighting cells.
- Click "Ok"
- Click "Ok"
- Click "Ok"

### Highlight common records from two lists Excel 2003

Conditional formatting formula:

How to highlight differences in price lists

Today I am going to show you how to quickly compare two tables using Conditional Formatting (CF). I am going […]

Compare two columns and highlight values in common

A conditional formatting formula highlights values in column B that also exist in column D. =COUNTIF($D$3:$D$7,B3) The same thing happens […]

Highlight missing values between to columns

The picture above shows two lists. How do I highlight values in List 1 that are not in List 2? […]

Remove common records between two data sets

This article demonstrates how to filter records occurring in only one out of two Excel defined tables. It also shows […]

Filter shared records from two tables

I will in this blog post demonstrate a formula that extracts common records (shared records) from two data sets in […]

Unique distinct records sorted based on count or frequency

Sara asks: How can you use large with multiple criteria?? Example looking for top 5 of a list based on […]

Compare tables: Highlight records not in both tables

The image above demonstrates a conditional formatting formula that highlights records that only exist in one table. There are two […]

### 2 Responses to “Compare two lists of data: Highlight common records”

### Leave a Reply

### How to comment

**How to add a formula to your comment**

<code>Insert your formula here.</code>

**Convert less than and larger than signs**

Use html character entities instead of less than and larger than signs.

< becomes < and > becomes >

**How to add VBA code to your comment**

[vb 1="vbnet" language=","]

Put your VBA code here.

[/vb]

**How to add a picture to your comment:**

Upload picture to postimage.org or imgur

Paste image link to your comment.

**Contact Oscar**

You can contact me through this contact form

Is there a way to do this with two worksheets instead of columns in the same worksheet?

I find myself going through each entry looking for the property ID in one worksheet to highlight it in the second worksheet, that way I know what properties are already registered with the City. However, this takes too much time. VLOOKUP will not work in this instance because it only returns one item that matches.

In my situation, I am looking for a function that will return (highlight) all of the matching property IDs in sheet 2 using the entries in sheet 1.

Any help would be greatly appreciated.

Georgina Ram

Sure, if this is the original conditional formatting formula on sheet "Sheet1":

COUNTIFS($A$2:$A$13, $A2, $B$2:$B$13, $B2, $C$2:$C$13, $C2)

and List 2 is now on sheet "Sheet2" then the formula becomes:

COUNTIFS(Sheet2!$A$2:$A$13, $A2, Sheet2!$B$2:$B$13, $B2, Sheet2!$C$2:$C$13, $C2)