Compare 2 Columns

How to compare the contain of 2 columns? Just one formula with 2 Excel functions returns the result

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.

Missing value in a list

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.


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


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


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


Function VLOOKUP to return the same value in the other column

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

When the value is not found, the VLOOKUP function returns N/A

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.


Transform the VLOOKUP function with the function ISNA

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:


The test returns the result expected

Change color of the missing values

When you have created a logical test (TRUE or FALSE) you can use it as custom rule 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:

  1. Select the range of cells where you want to apply your conditional formatting (here A1:A5)
  2. Open the menu Home>Conditional Formatting>New Rule
  3. Choose Use Formula to determine which cells the format will be applied to.
  4. In the text box, paste the formula that allowed us to return TRUE or FALSE (the ISNA function)
  5. Change formatting by clicking the Format button.
Copy of the formula as conditional formatting rules

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

Missing value are in red automatically

It is more visible to show the differences by a highlighting them in a different color when you compare 2 columns 😉

Tutorial video

In this video, you will turn up all the steps

Related posts

Permanent link to this article:

Leave a Reply

Your email address will not be published.

Ezoicreport this ad