## Live demo

Change some values in this worksheet (yes, it's a worksheet 😃). You will see that the color of the cell will change depending on whether or not the value exists in column E.

## Compare 2 columns

Comparing 2 columns in Excel is very easy.

Everything is based on the whether or not VLOOKUP finds a value in a specified column.

If you are not familiar with the VLOOKUP function, you will find an explanation of it in this post.

Many Excel users believe that when the function returns #N/A it signifies an error.

Not at all !#N/A means "I did not find the item you were looking for".

In the case of a comparison between two columns, **it is the value #N/A that will interest us.**

Thus, the "error" indicates where an element does not exist in both columns.

### Step 1: The VLOOKUP function

Let's start by typing our VLOOKUP function, and the first item you want to search,

in cell B1 . Here we want to find the contents of cell A1.

=VLOOKUP(A1,

Then, we will verify that this value is present in the column **$D$1:$D$4** (do not forget $ to lock the cell references 😉)

=VLOOKUP(A1,$D$1:$D$4,

We write **the third parameter = 1** (because we have selected only one column in second parameter).

=VLOOKUP(A1,$D$1:$D$4,1,

And **last parameter = 0** (to perform an exact match).

=VLOOKUP(A1,$D$1:$D$4,1,0)

Then copy the formula down the column. The missing value is immediately visible **by the #N/A error value **(NA means Not Applicable).

But it is not very visually appealing to display #N/A in your workbook 🙄🤨

### Step 2: Use the ISNA function to perform a test

We will use the ISNA function to customize the result. The function will return 2 values:

- TRUE: when the function VLOOKUP returns #N/A
- FALSE: when the function has matched

So now we will insert the previous formula **into an ISNA function.** The result returned by this new formula is TRUE or FALSE depending whether or not the search was successful.

=ISNA(VLOOKUP(A1,$D$1:$D$4,1,0))

### Step 3: Finish with the IF function

Displaying TRUE or FALSE is still not very aesthetically appealing, especially if you have to present this document to other people.

This is why we will integrate this test into an IF function to customize the result.

We can write the following IF function:

=IF(ISNA(VLOOKUP(A1,$D$1:$D$4,1,0)),"Missing","")

## Change color of the missing values

When you have created a logical test (TRUE or FALSE) you can use it as formula in a conditional formatting.

For example here, we will reuse the test with the **ISNA** function and copy it as a rule.

The steps are:

- Select column A
- Open the menu
**Home>Conditional Formatting>New Rule** - Choose
*Use Formula to determine which cells the format will be applied to*. - In
*the text box*, paste the formula that allowed us to return TRUE or FALSE (**the ISNA****function**) - Change formatting by clicking the
**Format**button**.**

The result is that cells in column A are displayed with a **red background** when the value is not found in the column D 😍😍😍

It is more visible to show the differences by a highlighting them in a different color 😊😉

## 3 comments

Beautiful. Did what I needed after a numerous searches. Thanks!

Thank you! It helped me a lot and made my work so much faster!

Awesome, this is going to make a lot of what I do much easier. Comes up a lot in IT where I have to match up two lists that match on a particular column, say computer hostnames, so I can pair information from the first list to info in the second list. Wish I'd known about this function years ago!