Compare two columns and highlight differences
This article demonstrates a conditional formatting formula that will highlight the differences between two columns. The image above shows two cell ranges containing values, the first one is in column B and the second one is in column D.
Values "BB", "GG", and "GG" are highlighted, they only exist in column B. Values "DD" and "FF" are highlighted, they only exist in column D.
Table of Contents
Conditional formatting is a built-in feature that allows you to format specific cells based on a condition or criteria.
The conditional formatting formula presented in this article highlights values that only exist in one column, in other words, they differ from the values in the other column. You can pick any format or fill color and the formula lets you build advanced criteria that must be met.
1. How to highlight values
- Select cell range B3:B7.
- Go to tab "Home" on the ribbon if you are not there already.
- Press with mouse on the Conditional Formatting button.
- Press with mouse on "New Rule...".
- Press with mouse on "Use a formula to determine which cells to format".
- Type: =AND($D$3:$D$7<>B3)
- Press with mouse on "Format..." button.
- Press with mouse on "Fill" tab.
- Pick a color.
- Press with left mouse button on OK.
- Press with left mouse button on OK.
Repeat above steps with column D, the formula is =AND($B$3:$B$7<>D3)
2. Explaining conditional formatting formula
Step 1 - Check if cell range D3:D7 is not equal to cell B3
Reference $D$3:$D$7 is an absolute cell reference meaning it is locked, it won't change when the CF moves to the next cell.
The less than and larger than sign combined means not equal to.
$D$3:$D$7<>B3
becomes
$D$3:$D$7<>B3
and returns {TRUE; TRUE; TRUE; TRUE; TRUE}.
Step 2 - Check if all boolean values are TRUE
AND($D$3:$D$7<>B3)
AND($D$3:$D$7<>B3)
becomes
AND({TRUE; TRUE; TRUE; TRUE; TRUE})
and returns TRUE. Cell B3 is highlighted.
3. Get Excel *.xlsx
Compare two columns and highlight differences.xlsx
Recommended reading
Built-in conditional formatting
Data Bars Color scales IconsHighlight cells rule
Highlight cells containing stringHighlight a date occuring
Highlight cells equal to
Highlight unique/duplicates
Top bottom rules
Highlight top 10 valuesHighlight top 10 % values
Highlight above average values
Basic CF formulas
Working with Conditional Formatting formulasFind numbers in close proximity to a given number
Highlight empty cells
Highlight text values
Search using CF
Highlight records – multiple criteria [OR logic]Highlight records [AND logic]
Highlight records containing text strings (AND Logic)
Highlight lookup values
Unique distinct
How to highlight unique distinct valuesHighlight unique values and unique distinct values in a cell range
Highlight unique values in a filtered Excel table
Highlight unique distinct records
Duplicates
How to highlight duplicate valuesHighlight duplicates in two columns
Highlight duplicate values in a cell range
Highlight smallest duplicate number
Highlight more than once taken course in any given day
Highlight duplicates with same date, week or month
Highlight duplicate records
Highlight duplicate columns
Highlight duplicates in a filtered Excel Table
Compare
Highlight missing values between to columnsCompare two columns and highlight values in common
Compare two lists of data: Highlight common records
Compare tables: Highlight records not in both tables
How to highlight differences in price lists
Compare two columns and highlight differences
Min max
Highlight smallest duplicate numberHow to highlight MAX and MIN value based on month
Highlight closest number
Dates
Highlight dates in a date rangeHow to highlight MAX and MIN value based on month
Highlight odd/even months
Highlight overlapping date ranges using conditional formatting
Highlight records based on overlapping date ranges and a condition
Highlight date ranges overlapping selected record [VBA]
How to highlight weekends [Conditional Formatting]
How to highlight dates based on day of week
Highlight current date
Misc
Highlight every other rowDynamic formatting
How to change cell formatting using a Drop Down list
Highlight cells based on ranges
Highlight opposite numbers
Highlight cells based on coordinates
Excel categories
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.