Compare column to column excel

Watch Video – Compare two Columns in Excel for matches and differences

The one query that I get a lot is – ‘how to compare two columns in Excel?’.

This can be done in many different ways, and the method to use will depend on the data structure and what the user wants from it.

For example, you may want to compare two columns and find or highlight all the matching data points (that are in both the columns), or only the differences (where a data point is in one column and not in the other), etc.

Since I get asked about this so much, I decided to write this massive tutorial with an intent to cover most (if not all) possible scenarios.

If you find this useful, do pass it on to other Excel users.

Note that the techniques to compare columns shown in this tutorial are not the only ones.

Based on your dataset, you may need to change or adjust the method. However, the basic principles would remain the same.

If you think there is something that can be added to this tutorial, let me know in the comments section

Compare Two Columns For Exact Row Match

This one is the simplest form of comparison. In this case, you need to do a row by row comparison and identify which rows have the same data and which ones does not.

Example: Compare Cells in the Same Row

Below is a data set where I need to check whether the name in column A is the same in column B or not.

Compare Columns - row by row - dataset

If there is a match, I need the result as “TRUE”, and if doesn’t match, then I need the result as “FALSE”.

The below formula would do this:

=A2=B2

Compare Lists in Excel - matches are shown as TRUE

Example: Compare Cells in the Same Row (using IF formula)

If you want to get a more descriptive result, you can use a simple IF formula to return “Match” when the names are the same and “Mismatch” when the names are different.

=IF(A2=B2,"Match","Mismatch")

If formula to compare columns in Excel

Note: In case you want to make the comparison case sensitive, use the following IF formula:

=IF(EXACT(A2,B2),"Match","Mismatch")

With the above formula, ‘IBM’ and ‘ibm’ would be considered two different names and the above formula would return ‘Mismatch’.

Example: Highlight Rows with Matching Data

If you want to highlight the rows that have matching data (instead of getting the result in a separate column), you can do that by using Conditional Formatting.

Here are the steps to do this:

  1. Select the entire dataset.
  2. Click the ‘Home’ tab.Click the Home Tab in the Excel ribbon
  3. In the Styles group, click on the ‘Conditional Formatting’ option.Click on Conditional Formatting
  4. From the drop-down, click on ‘New Rule’.Click on the New Rule option
  5. In the ‘New Formatting Rule’ dialog box, click on the ‘Use a formula to determine which cells to format’.Click on Use Formula option
  6. In the formula field, enter the formula: =$A1=$B1Formula to compare columns in Conditional Formatting
  7. Click the Format button and specify the format you want to apply to the matching cells.Set Formatting in conditional formatting
  8. Click OK.

This will highlight all the cells where the names are the same in each row.

Compare two columns and highlight matching rows

Compare Two Columns and Highlight Matches

If you want to compare two columns and highlight matching data, you can use the duplicate functionality in conditional formatting.

Note that this is different than what we have seen when comparing each row. In this case, we will not be doing a row by row comparison.

Example: Compare Two Columns and Highlight Matching Data

Often, you’ll get datasets where there are matches, but these may not be in the same row.

Something as shown below:

Compare two columns and highlight macthes - dataset

Note that the list in column A is bigger than the one in B. Also some names are there in both the lists, but not in the same row (such as IBM, Adobe, Walmart).

If you want to highlight all the matching company names, you can do that using conditional formatting.

Here are the steps to do this:

  1. Select the entire data set.
  2. Click the Home tab.
  3. In the Styles group, click on the ‘Conditional Formatting’ option.Click on Conditional Formatting
  4. Hover the cursor on the Highlight Cell Rules option.
  5. Click on Duplicate Values.Select Duplicate Values in Conditional Formatting
  6. In the Duplicate Values dialog box, make sure ‘Duplicate’ is selected.Duplicate in Conditional Formatting
  7. Specify the formatting.Specify the formatting in conditional formatting
  8. Click OK.

The above steps would give you the result as shown below.

Highlighted matching data when comparing lists in Excel

Note: Conditional Formatting duplicate rule is not case sensitive. So ‘Apple’ and ‘apple’ are considered the same and would be highlighted as duplicates.

Example: Compare Two Columns and Highlight Mismatched Data

In case you want to highlight the names which are present in one list and not the other, you can use the conditional formatting for this too.

  1. Select the entire data set.
  2. Click the Home tab.
  3. In the Styles group, click on the ‘Conditional Formatting’ option.Click on Conditional Formatting
  4. Hover the cursor on the Highlight Cell Rules option.
  5. Click on Duplicate Values.Select Duplicate Values in Conditional Formatting
  6. In the Duplicate Values dialog box, make sure ‘Unique’ is selected.Select Unique to highlight differences
  7. Specify the formatting.Specify the formatting to highlight differences in two columns
  8. Click OK.

This will give you the result as shown below. It highlights all the cells that have a name that is not present on the other list.

Compare Two columns and highlight differences

Compare Two Columns and Find Missing Data Points

If you want to identify whether a data point from one list is present in the other list, you need to use the lookup formulas.

Suppose you have a dataset as shown below and you want to identify companies that are present in column A but not in Column B,

Compare two columns and highlight macthes - dataset

To do this, I can use the following VLOOKUP formula.

=ISERROR(VLOOKUP(A2,$B$2:$B$10,1,0))

This formula uses the VLOOKUP function to check whether a company name in A is present in column B or not. If it is present, it will return that name from column B, else it will return a #N/A error.

These names which return the #N/A error are the ones that are missing in Column B.

ISERROR function would return TRUE if there is the VLOOKUP result is an error and FALSE if it isn’t an error.

compare lists and find missing data

If you want to get a list of all the names where there is no match, you can filter the result column to get all cells with TRUE.

You can also use the MATCH function to do the same;

=NOT(ISNUMBER(MATCH(A2,$B$2:$B$10,0)))

Note: Personally, I prefer using the Match function (or the combination of INDEX/MATCH) instead of VLOOKUP. I find it more flexible and powerful. You can read the difference between Vlookup and Index/Match here.

Compare Two Columns and Pull the Matching Data

If you have two datasets and you want to compare items in one list to the other and fetch the matching data point, you need to use the lookup formulas.

Example: Pull the Matching Data (Exact)

For example, in the below list, I want to fetch the market valuation value for column 2. To do this, I need to look up that value in column 1 and then fetch the corresponding market valuation value.

Compare two lists in Excel and fetch matching data

Below is the formula that will do this:

=VLOOKUP(D2,$A$2:$B$14,2,0)

or

=INDEX($A$2:$B$14,MATCH(D2,$A$2:$A$14,0),2)

Lookup and Pull matching data - market valuation Excel

Example: Pull the Matching Data (Partial)

In case you get a dataset where there is a minor difference in the names in the two columns, using the above-shown lookup formulas is not going to work.

These lookup formulas need an exact match to give the right result. There is an approximate match option in VLOOKUP or MATCH function, but that can’t be used here.

Suppose you have the data set as shown below. Note that there are names that are not complete in Column 2 (such as JPMorgan instead of JPMorgan Chase and Exxon instead of ExxonMobil).

Pull matching Data - partial match

In such a case, you can use a partial lookup by using wildcard characters.

The following formula will give is the right result in this case:

=VLOOKUP("*"&D2&"*",$A$2:$B$14,2,0)

or

=INDEX($A$2:$B$14,MATCH("*"&D2&"*",$A$2:$A$14,0),2)

Partial comparison in columns with wildcard characters

In the above example, the asterisk (*) is a wildcard character that can represent any number of characters. When the lookup value is flanked with it on both sides, any value in Column 1 which contains the lookup value in Column 2 would be considered as a match.

For example, *Exxon* would be a match for ExxonMobil (as * can represent any number of characters).

You May Also Like the Following Excel Tips & Tutorials:

  • How to Compare Two Excel Sheets (for differences)
  • How to Highlight Blank Cells in Excel.
  • How to Compare Text in Excel (Easy Formulas)
  • Highlight EVERY Other ROW in Excel.
  • Excel Advanced Filter: A Complete Guide with Examples.
  • Highlight Rows Based on a Cell Value in Excel
  • How to Compare Dates in Excel (Greater/Less Than, Mismatches)

Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Office for business Excel 2010 Excel 2007 More…Less

You can use the following methods to compare data in two Microsoft Excel worksheet columns and find duplicate entries. 

Method 1: Use a worksheet formula

  1. Start Excel.

  2. In a new worksheet, enter the following data as an example (leave column B empty):

    A

    B

    C

    1

    1

    3

    2

    2

    5

    3

    3

    8

    4

    4

    2

    5

    5

    0

  3. Type the following formula in cell B1:

    =IF(ISERROR(MATCH(A1,$C$1:$C$5,0)),»»,A1)

  4. Select cell B1 to B5.

  5. In Excel 2007 and later versions of Excel, select Fill in the Editing group, and then select Down.

    The duplicate numbers are displayed in column B, as in the following example: 

    A

    B

    C

    1

    1

    3

    2

    2

    2

    5

    3

    3

    3

    8

    4

    4

    2

    5

    5

    5

    0

Method 2: Use a Visual Basic macro

Warning: Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure. However, they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

To use a Visual Basic macro to compare the data in two columns, use the steps in the following example:

  1. Start Excel.

  2. Press ALT+F11 to start the Visual Basic editor.

  3. On the Insert menu, select Module.

  4. Enter the following code in a module sheet:

    Sub Find_Matches()
    Dim CompareRange As Variant, x As Variant, y As Variant
    ' Set CompareRange equal to the range to which you will
    ' compare the selection.
    Set CompareRange = Range("C1:C5")
    ' NOTE: If the compare range is located on another workbook
    ' or worksheet, use the following syntax.
    ' Set CompareRange = Workbooks("Book2"). _
    ' Worksheets("Sheet2").Range("C1:C5")
    '
    ' Loop through each cell in the selection and compare it to
    ' each cell in CompareRange.
    For Each x In Selection
    For Each y In CompareRange
    If x = y Then x.Offset(0, 1) = x
    Next y
    Next x
    End Sub

  5. Press ALT+F11 to return to Excel.

    1. Enter the following data as an example (leave column B empty):
       

      A

      B

      C

      1

      1

      3

      2

      2

      5

      3

      3

      8

      4

      4

      2

      5

      5

      0

  6. Select cell A1 to A5.

  7. In Excel 2007 and later versions of Excel, select the Developer tab, and then select Macros in the Code group.

    Note: If you don’t see the Developer tab, you may have to turn it on. To do this, select File > Options > Customize Ribbon, and then select the Developer tab in the customization box on the right-side.

  8. Click Find_Matches, and then click Run.

    The duplicate numbers are displayed in column B. The matching numbers will be put next to the first column, as illustrated here:

    A

    B

    C

    1

    1

    3

    2

    2

    2

    5

    3

    3

    3

    8

    4

    4

    2

    5

    5

    5

    0

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Two columns in excel are compared when their entries are studied for similarities and differences. The similarities are the data values that exist in the same row of both the compared columns. In contrast, the differences are those values that exist in only one of these columns.

For example, for a specific month, a table displays the following information:

  • Column A lists the names of the employees who took three consecutive leaves.
  • Column B lists the names of the employees who took two consecutive leaves.

Since the data pertains to the same organization, there can be a similarity or a difference within the given set of values. The same is explained as follows:

  • A similarity or a match (column A is equal to column B) implies employees who took both three and two continuous leaves.
  • A difference (column A is not equal to column B) implies employees who took either three or two continuous leaves.

It is difficult to scan through the data to track the matches and the differences manually. Hence, there are techniques which can be followed to compare 2 columns of an excel worksheet.

Table of contents
  • Compare two Columns in Excel
    • How to Compare two Columns in Excel? (Top 4 Methods)
      • #1 – Compare Using Simple Formulae
      • #2 – Compare 2 Columns Using the IF Formula
      • #3 – Compare Using the EXACT Formula
      • #4 – Compare 2 Excel Columns Using Conditional Formatting
    • The Properties of the Comparison Methods
    • Frequently Asked Questions
    • Recommended Articles

How to Compare two Columns in Excel? (Top 4 Methods)

The top four methods to compare 2 columns are listed as follows:

  • Method #1–Compare using simple formulae
  • Method #2–Compare using the IF formula
  • Method #3–Compare using the EXACT formula
  • Method #4–Compare using conditional formatting

Let us understand these methods with the help of examples.

You can download this Compare Two Columns Excel Template here – Compare Two Columns Excel Template

#1 – Compare Using Simple Formulae

The following table shows the names of the employees of an organization in column A. Columns B and C display their log-in and the log-out times respectively.

We want to compare two excel columns B and C to find out the employees who forgot to logout from the office. The official timings are 10:30 a.m.-7:30 p.m. Use the formula method for comparison.

Compare Two Columns Method 1

For the given data, if the log-in time is equal to the log-out time, we assume that the employee has forgotten to logout.

The steps to compare two columns in excel with the help of the comparison operator “equal to” (=) are listed as follows:

  1. In cell D2, enter the symbol “=” followed by selecting the cell B2.

    Compare Two Columns Method 1-1

  2. Enter the symbol “=” again, followed by selecting the cell C2.

    Compare Two Columns Method 1-2

  3. Press the “Enter” key. It returns “false.” This implies that the value in cell B2 is not equal to that of cell C2.

    Compare Two Columns Method 1-3

  4. Drag or copy-paste the formula to the remaining cells. The output is either “true” or “false,” as shown in the following image.
    If the value in column B is equal to that of column C, the result is “true,” else “false.” The cells D5 and D9 show the output “true.”
    Hence, Roshan and Uday forgot to logout from the office.

    Compare Two Columns Method 1-4

#2 – Compare 2 Columns Using the IF Formula

Working on the data of example #1, we want the following results:

  • “Forgot to punch out,” if the employee forgets to logout
  • “No problem,” if the employee logs out

Use the IF functionIF function in Excel evaluates whether a given condition is met and returns a value depending on whether the result is “true” or “false”. It is a conditional function of Excel, which returns the result based on the fulfillment or non-fulfillment of the given criteria.
read more
to compare the columns B and C.

We apply the following formula.

“=IF(B2=C2,“Forgot to Punch Out”,“No Problem”)”

If the value in column B is equal to that of column C, the result is “true,” otherwise “false.” For every “true” value, the formula returns “forgot to punch out.” Likewise, it returns “no problem” for every “false” value.

The output is shown in column E of the following image.

Hence, Roshan and Uday are the only two employees who have forgotten to logout from the office.

Compare Two Columns Method 2

#3 – Compare Using the EXACT Formula

Working on the data of example #1, we want to compare the two excel columns B and C with the help of the EXACT functionThe exact function is a logical function in excel used to compare two strings or data with each other, and it gives us the result whether the both data are an exact match or not. This function is a logical function, so it provides true or false as a result.read more.

We apply the following formula.

“=EXACT(B2,C2)”

If the value in column B is equal to that of column C, the formula returns “true,” otherwise “false.” The output is shown in column F of the following image.

Hence, the entries of columns B and C are identical for Roshan and Uday.

Note: The EXACT function is case-sensitive.

Compare Two Columns Method 3

We have written the name “Raman” in columns A and B with different casing. We apply the following formula.

“=EXACT(A2,B2)”

The formula returns “false” when the casing of cell A2 is different from that of cell B2. Likewise, it returns “true” if the casing in columns A and B is the same.

The output is shown in column C of the following image.

Compare Two Columns Method 3-1

#4 – Compare 2 Excel Columns Using Conditional Formatting

Working on the data of example #1, we want to highlight those entries that are identical in columns B and C. Use the conditional formattingConditional formatting is a technique in Excel that allows us to format cells in a worksheet based on certain conditions. It can be found in the styles section of the Home tab.read more feature.

Compare Two Columns Method 4

Step 1: Select the entire data. In the Home tab, click the “conditional formatting” drop-down under the “styles” section. Select “new rule.”

Compare Two Columns Method 4-1

Step 2: The “new formatting rule” window appears. Under “select a rule type,” choose the option “use a formula to determine which cells to format.”

Method 4-2

Step 3: Enter the formula “$B2=$C2” under “edit the rule description.”

Method 4-3

Step 4: Click “format.” In the “format cells” window, select the color to highlight the identical entries. Click “Ok.” Click “Ok” again in the “new formatting rule” window.

Method 4-4

Step 5: The matches of columns B and C are highlighted, as shown in the following image.

Hence, the entries of columns B and C are identical for Roshan and Uday.

Method 4-5

The Properties of the Comparison Methods

The features of the comparison methods discussed are listed as follows:

  • The outcomes of the IF function can be modified according to the requirement of the user.
  • The EXACT function returns “false” for two same values having different casing.
  • The simplest technique to compare two excel columns is by using the comparison operator “equal to” (method #1).

Note: The comparison method to be used depends on the data structure and the kind of output required.

Frequently Asked Questions

1. What does it mean to compare two columns and how is it done in Excel?

The comparison of two data columns helps find the similarities and the differences. In case of similarity, a value exists in the same row of both the columns. In contrast, a difference is a deviation of one value from the other.

To compare two excel columns, the easiest approach is listed as follows:
a. Enter the following formula.
“=cell1=cell2”
The “cell1” is a cell containing a data value in the first column. The “cell2” is a cell containing a data value in the second column. Both “cell1” and “cell2” are in the same row.
b. Press the “Enter” key.
The formula returns “true” or “false” depending on whether the value exists in both the compared columns or not.

2. How to highlight the different values of two columns without using the formula in Excel?

Let us compare the following 2 columns consisting of names in the mentioned sequence:
• Column A contains Jack, Adam, Elizabeth, Betty, and Veronica.
• Column B contains Robert, Peter, Elizabeth, Henry, and Veronica.

The steps to highlight the different values without using the formula are listed as follows:

a. Select columns A and B.
b. In the Home tab, click “find and select” drop-down under the “editing” group. Choose “go to special.”
c. In the “go to special” window, select “row differences.” Click “Ok.”

The names Robert, Peter, and Henry of column B are highlighted. These cells can be colored using the “fill color” property of Excel.

3. How to compare multiple columns in Excel?

Let us compare the following columns consisting of numbers in the mentioned sequence:

• Column A contains 3, 49, 20, 22, and 86 in the range A1:A5.
• Column B contains 29, 49, 38, 21, and 86 in the range B1:B5.
• Column C contains 12, 49, 56, 24, and 86 in the range C1:C5.

The steps to compare columns A, B, and C are stated as follows:

a. Enter the following formula in cell D1. “IF(COUNTIF($A1:$C5,$A1)=3,“full match”,“”)”
b. Press the “Enter” key.
c. Drag or copy-paste the formula to the remaining cells.

Since we are comparing three excel columns, we enter the number 3 in the formula. The formula returns “full match” in cells D2 and D5. It returns an empty string in the cells D1, D3, and D4.

Hence, the numbers 49 and 86 appear in the respective rows 2 and 5 of all the three columns.

Recommended Articles

This has been a guide to compare two columns in Excel. Here we discussed the top 4 methods to compare 2 columns in Excel, 1) the operator “equal to”, 2) IF function, 3) EXACT formula, and 4) conditional formatting. We also went through some practical examples. You can download the Excel template from the website. For more on Excel, take a look at the following articles-

  • Freeze Columns in ExcelFreezing columns in excel fixes or locks them so that they remain visible while scrolling through the database. A frozen column does not move with the movement of the remaining columns.read more
  • Excel Rows to ColumnsRows can be transposed to columns by using paste special method and the data can be linked to the original data by simply selecting ‘Paste Link’ form the paste special dialog box. It could also be done by using INDIRECT formula and ADDRESS functions.read more
  • Count Only Unique Values in ExcelIn Excel, there are two ways to count values: 1) using the Sum and Countif function, and 2) using the SUMPRODUCT and Countif function.read more
  • Advanced Filter in ExcelThe advanced filter is different from the auto filter in Excel. This feature is not like a button that one can use with a single click of the mouse. To use an advanced filter, we have to define criteria for the auto filter and then click on the “Data” tab. Then, in the advanced section for the advanced filter, we will fill our criteria for the data.read more

When you’re working with data in Excel, sooner or later you will have to compare data. This could be comparing two columns or even data in different sheets/workbooks.

In this Excel tutorial, I will show you different methods to compare two columns in Excel and look for matches or differences.

There are multiple ways to do this in Excel and in this tutorial I will show you some of these (such as comparing using VLOOKUP formula or IF formula or Conditional formatting).

So let’s get started!

Compare Two Columns (Side by Side)

This is the most basic type of comparison where you need to compare a cell in one column with the cell in the same row in another column.

Suppose you have a dataset as shown below and you simply want to check whether the value in column A in a specific cell is the same (or different) when compared with the value in the adjacent cell.

Compare-Two-Columns-in-Excel-for-matches-dataset

Of course, you can do this when you have a small dataset when you have a large one, you can use a simple comparison formula to get this done. And remember, there is always a chance of human error when you do this manually.

So let me show you a couple of easy ways to do this.

Compare Side by Side Using the Equal to Sign Operator

Suppose you have the below dataset and you want to know what rows have the matching data and what rows have different data.

Compare-Two-Columns-in-Excel-for-matches-dataset

Below is a simple formula to compare two columns (side by side):

=A2=B2

Formula-to-compare-two-cells-side-by-side

The above formula will give you a TRUE if both the values are the same and FALSE in case they are not.

Now, if you need to know all the values that match, simply apply a filter and only show all the TRUE values. And if you want to know all the values that are different, filter all the values that are FALSE (as shown below):

Filtered-to-find-differences

When using this method to do column comparison in Excel, it’s always best to check that your data does not have any leading or trailing spaces. If these are present, despite having the same value, Excel will show them as different. Here is a great guide on how to remove leading and trailing spaces in Excel.

Compare Side by Side Using the IF Function

Another method that you can use to compare two columns can be by using the IF function.

This is similar to the method above where we used the equal to (=) operator, with one added advantage. When using the IF function, you can choose the value you want to get when there are matches or differences.

For example, if there is a match, you can get the text “Match” or can get a value such as 1. Similarly, when there is a mismatch, you can program the formula to give you the text “Mismatch” or give you a 0 or blank cell.

Below is the IF formula that returns ‘Match’ when the two cells have the cell value and ‘Not a Match’ when the value is different.

=IF(A2=B2,"Match","Not a Match")

Compare-columns-using-the-IF-formula

The above formula uses the same condition to check whether the two cells (in the same row) have matching data or not (A2=B2). But since we are using the IF function, we can ask it to return a specific text in case the condition is True or False.

Once you have the formula results in a separate column, you can quickly filter the data and get rows that have the matching data or rows with mismatched data.

Also read: Does Not Equal Operator in Excel (Examples)

Highlight Rows with Matching Data (or Different Data)

Another great way to quickly check the rows that have matching data (or have different data), is to highlight these rows using conditional formatting.

You can do both – highlight rows that have the same value in a row as well as the case when the value is different.

Suppose you have a dataset as shown below and you want to highlight all the rows where the name is the same.

Compare-names-in-two-columns

Below are the steps to use conditional formatting to highlight rows with matching data:

  1. Select the entire dataset (except the headers)
  2. Click the Home tabClick-the-Home-tab
  3. In the Styles group, click on Conditional FormattingClick-on-Conditional-Formatting
  4. In the options that show up, click on ‘New Rule’Click-on-New-Rule
  5. In the ‘New Formatting Rule’ dialog box, click on the option -”Use a formula to determine which cells to format’Click-on-Use-a-formula-to-determine-which-cells-to-format
  6. In the ‘Format values where this formula is true’ field, enter the formula: =$A2=$B2Enter-the-formula-in-Conditional-Formatting-dialog-box
  7. Click on the Format buttonClick-on-the-Format-button
  8. Click on the ‘Fill’ tab and select the color in which you want to highlight the rows with the same value in both columnsSelect-the-color-from-Fill-tab
  9. Click OK

The above steps would instantly highlight the rows where the name is the same in both columns A and B (in the same row). And in the case where the name is different, those rows will not be highlighted.

Compare-two-columns-and-highlight-matching-cells

In case you want to compare two columns and highlight rows where the names are different, use the below formula in the conditional formatting dialog box (in step 6).

=$A2<>$B2

How does this work?

When we use conditional formatting with a formula, it only highlights those cells where the formula is true.

When we use $A2=$B2, it will check each cell (in both columns) and see whether the value in a row in column A is equal to the one in column B or not.

In case it’s an exact match, it will highlight it in the specified color, and in case it doesn’t match, it will not.

The best part about conditional formatting is that it doesn’t require you to use a formula in a separate column. Also, when you apply the rule on a dataset, it remains dynamic. This means that if you change any name in the dataset, conditional formatting will accordingly adjust.

Compare Two Columns Using VLOOKUP (Find Matching/Different Data)

In the above examples, I showed you how to compare two columns (or lists) when we are just comparing side by side cells.

In reality, this is rarely going to be the case.

In most cases, you will have two columns with data and you would have to find out whether a data point in one column exists in the other column or not.

In such cases, you can’t use a simple equal-to sign or even an IF function.

You need something more powerful…

… something that’s right up VLOOKUP’s alley!

Let me show you two examples where we compare two columns in Excel using the VLOOKUP function to find matches and differences.

Compare Two Columns Using VLOOKUP and Find Matches

Suppose we have a dataset as shown below where we have some names in columns A and B.

Compare-names-in-two-columns

If you have to find out what are the names that are in column B that are also in column A, you can use the below VLOOKUP formula:

=IFERROR(VLOOKUP(B2,$A$2:$A$10,1,0),"No Match")

Compare-Two-columns-to-get-matching-data-using-vlookup

The above formula compares the two columns (A and B) and gives you the name in case the name is in column B as well A, and it returns “No Match” in case the name is in Column B and not in Column A.

By default, the VLOOKUP function will return a #N/A error in case it doesn’t find an exact match. So to avoid getting the error, I have wrapped the VLOOKUP function in the IFERROR function, so that it gives “No Match” when the name is not available in column A.

You can also do the other way round comparison – to check whether the name is in Column A as well as Column B. The below formula would do that:

=IFERROR(VLOOKUP(A2,$B$2:$B$6,1,0),"No Match")

Compare Two Columns Using VLOOKUP and Find Differences (Missing Data Points)

While in the above example, we checked whether the data in one column was there in another column or not.

You can also use the same concept to compare two columns using the VLOOKUP function and find missing data.

Suppose we have a dataset as shown below where we have some names in columns A and B.

Compare-two-columns-in-Excel-using-VLOOKUP-Dataset

If you have to find out what are the names that are in column B that not there in column A, you can use the below VLOOKUP formula:

=IF(ISERROR(VLOOKUP(B2,$A$2:$A$10,1,0)),"Not Available","Available")

Compare-Two-columns-to-get-missing-data-using-vlookup

The above formula checks the name in column B against all the names in Column A. In case it finds an exact match, it would return that name, and in case it doesn’t find and exact match, it will return the #N/A error.

Since I am interested in finding the missing names that are there is column B and not in column A, I need to know the names that return the #N/A error.

This is why I have wrapped the VLOOKUP function in the IF and ISERROR functions. This whole formula gives the value – “Not Available” when the name is missing in Column A, and “Available” when it’s present.

To know all the names that are missing, you can filter the result column based on the “Not Available” value.

You can also use the below MATCH function to get the same result:

=IF(ISNUMBER(MATCH(B2,$A$2:$A$10,0)),"Available","Not Available")

Common Queries when Comparing Two Columns

Below are some common queries I usually get when people are trying to compare data in two columns in Excel.

Q1. How to compare multiple columns in Excel in the same row for matches? Count the total duplicates also.

Ans. We have given the procedure to compare two columns in excel for the same row above. But if you want to compare multiple columns in excel for the same row then see the example

=IF(AND(A2=B2, A2=C2),"Full Match", "")

Here we have compared data of column A, column B, and column C. After this, I have applied the above formula in column D and get the result.

Excel-compare-two-columns

Now to count the duplicates, you need to use the Countif function.

=IF(COUNTIF($A2:$E2, $A2)=5, "Full Match", "")

Q2. Which operator do you use for matches and differences?

Ans. Below are the operators to use:

  • To find matches, use the equal to sign (=)
  • To find differences (mismatches), use the not-equal-to sign (<>)

Q3. How to compare two different tables and pull matching data?

Ans. For this, you can use the VLOOKUP function or INDEX & MATCH function. To understand this thing in a better way we will take an example.

Here we will take two tables and now want to do pull matching data. In the first table, you have a dataset and in the second table, take the list of fruits and then use pull matching data in another column. For pull matching, use the formula

=INDEX($B$2:$B$6,MATCH($D2,$A$2:$A$6,0))

Index

Q4. How to remove duplicates in Excel?

Ans. To remove duplicate data you need to first find the duplicate values.

To find the duplicate, you can use various methods like conditional formatting, Vlookup, If Statement, and many more. Excel also has an in-built tool where you can just select the data, and remove the duplicates from a column or even multiple columns

Q5. I can see that there is a matching value in both columns. However, the formulas you have shared above are not considering these as exact matches. Why?

Ans: Excel considers something an exact match when each and every character of one cell is equal to the other. There is a high chance that in your dataset there are leading or trailing spaces.

Although these spaces may still make the values seem equal to a naked eye, for Excel these are different. If you have such a dataset, it’s best to get rid of these spaces (you can use Excel functions such as TRIM for this).

Q7. How to compare two columns that give the result as TRUE when all first columns’ integer values are not less than the second column’s integer values. To solve this problem, I do not require conditional formatting, Vlookup function, If Statement, and any other formulas. I need the formula to solve this problem.

Ans. You can use the array formula for solving this problem.

The syntax is {=AND(H6:H12>I6:I12)}. This will give you “True” as a result whenever the value of Column H is greater than the value in column I else “False” will be the result.

You may also like the following Excel tutorials:

  • Compare Two Columns in Excel (for matches and differences)
  • How to Remove Blank Columns in Excel? (Formula + VBA)
  • How to Hide Columns Based On Cell Value in Excel
  • How to Split One Column into Multiple Columns in Excel
  • How to Select Alternate Columns in Excel (or every Nth Column)
  • How to Paste in a Filtered Column Skipping the Hidden Cells
  • Best Excel Books (that will make you an Excel Pro)
  • How to Flip Data in Excel (Columns, Rows, Tables)?
  • Find the Closest Match in Excel (Nearest Value)
  • How to Compare Two Cells in Excel?
  • VLOOKUP Not Working – 7 Possible Reasons + How to Fix!
Skip to content

How to Compare Two Columns in Excel: Step-by-Step

How to Compare Two Columns in Excel: Step-by-Step

Comparing two columns in Excel is something you’d need to do very often. Sometimes to see if both the columns tally. And the other times, to see if both the columns are unique to each other 👀

In both cases, Excel fails to offer any in-built feature to help you do that. Yeah, very unfortunate – but that’s how it is.

However, there are still many hacks that you can use to compare two columns in Excel.

To learn those, continue reading the guide below 👇

Also, download our free sample workbook here to tag along with the guide.

Compare two columns to find matches & differences

Comparing two columns to spot-matching data in Excel is all about putting an IF function in place 😎

For example, the image below has two lists.

Two lists of names

Both lists contain names that apparently seem the same. But we still need to run a check to see if they are actually the same.

Oh no! Don’t start scanning the lists already. We have a hack to do that.

  1. In a neighboring column to the lists (Column C), write the IF function as below:

= IF (

Writing the IF function in a separate column
  1. As the first argument, write in the logical test to be performed by the IF function.

= IF (A2=B2

Specifying the logical test

We want to see if the first and the second list match. And so, we have set the logical test to be performed to Cell A2=B2. Excel would now check if Cell A2 is equal to B2 🚀

  1. As the second argument, type in the value that you’d want to be returned if the logical test turns true (value_if_true).

You can set any value as the value_in_true enclosed in double quotation marks. For now, we are setting it to “Names match”.

= IF (A2=B2, “Names match”

Specifying the value_if_true
  1. For the value_if_false, type in the value that you’d want to be returned if the logical test turns false.

Let’s set it to “Names don’t match”.

= IF (A2=B2, “Names match”, ”Names don’t match”)

Specifying the value_if_false

With this, we are all done writing the IF function 👍

  1. Hit “Enter” to get the results as follows:
Both the cells have the same value

The result is “Names match” for the first row of the list. And we can clearly see the same name “Charles” in both lists.

  1. Drag and drop the formula till the end (until the lists continue).
IF function applied to the whole list

The whole list is now checked for the same data. And for some names (in Rows 3, 4, and 7), the IF function returns “Names don’t match” ❌

Pay attention to the dataset to note that for:

  • Row 3: The spelling of “Tilbury” and “Tillbury” differs.
  • Row 4: “Samia” and “Leon” are clearly two different names.
  • Row 7: “Peter” and “Tim” are clearly two different names.

Kasper Langmann, Microsoft Office Specialist

This is one way how you can compare columns in Excel to know if both of the columns match or not. Such a row-to-row comparison also helps identify the individual items that differ (like Row 3,4, and 7 above) 🚴‍♀️

Compare two columns for case-sensitive matches

Take a quick look at the image below (Row 5).

The text “Pesso” in the first list starts with a capital P. Whereas, the text “pesso” in the second list starts with a small “p” 👆

However, the IF function treats them the same and returns the value “Names Match”.

This means that the IF function performs a case-insensitive comparison. But what if you want to run a case-sensitive comparison of two lists? Not a problem – we can do that too. See below.

  1. Write the EXACT function as below:

= EXACT (A2,B2)

The EXACT function checks if two given cells (A2 and B2) have exactly the same value. It also checks for case sensitivity.

It returns TRUE if both the cells are equal, and FALSE if they are not exactly equal.

EXACT function returns TRUE

For the first row, the EXACT function returned TRUE. That’s because the name “Charles” in the first column is exactly the same as “Charles” in the second column.

  1. Nest the EXACT function above in the IF function as follows.

= IF ( EXACT (A2,B2)

Nesting the EXACT function in the IF function

This will act as the logical test. If the EXACT function returns TRUE, the IF function will return the value_if_true.

And if the EXACT function returns FALSE, the IF function will return the value_if_false 🎯

  1. Type in the value that you’d want to be returned if the EXACT function returns TRUE.

We are again setting it to “Names match”.

= IF ( EXACT (A2,B2), “Names match”

Specifying the value_if_true
  1. Type in the value that you’d want to be returned if the EXACT function returns FALSE.

= IF ( (EXACT(A2, B2), “Names match”, ”Names don’t match”)

Specifying the value_if_false
  1. Hit “Enter”.
The IF function returns the results
  1. Drag and drop the formula to the whole list.
 IF function applied to the whole list

Note that this time, the results for the same Row 5 (Pesso) change 🤩

The IF function now tells us that the names do not match because they do not have the same case.

Highlight matches or differences between two columns

If you don’t want a whole separate list of formulas and results while you compare two columns – no worries, we hear you.

Another efficient way to compare columns is by running conditional formatting in Excel. You can use it to identify matching and differing columns, both 🎨

Let’s see how.

  1. Select the lists that you want to compare. If you don’t want both lists to be highlighted, you may select any one list only.
Selection of multiple columns
  1. Go to Home Tab > Conditional Formatting.
Conditional formatting
  1. From the drop-down list that appears, select Highlight Cell Rules option > More Rules.
More cell highlighting rules

This will take you to the “New Formatting Rule” dialog box as follows:

Highlight cell rules options
  1. Under Rule Type, select “Use a formula to determine which cells to format”.
  2. Under the Rule description, write the following formula:

=$A2=$B2

Setting the formatting rules to compare data

This tells Excel to format the cells where cell A2 is equal to cell B2.

We have turned the column reference into an absolute one so that the same formatting can be applied to the whole list 📝

Kasper Langmann, Microsoft Office Specialist
  1. Click on the “Format” button to select any Format that you’d want to be applied to the cells of the list that match.

We have selected the Fill option in green color as below.

Setting the formatting color
  1. All done – Click “Okay”.
Excel format the cells that have matching values

Excel highlights all the rows that match 📌

Pro Tip!

Did you note Row 5 (Pesso) being highlighted in green? This means conditional formatting also carries out a case-insensitive comparison of columns.

Similarly, if you want to apply conditional formatting to those rows of the lists that do not match:

  1. Launch the “New Formatting Rule” dialog box.
  2. Under Rule Type, select “Use a formula to determine which cells to format”.
  3. Under the Rule description, write the following formula:

=$A2<>$B2

Setting the formatting rules

This tells Excel to format the cells where cell A2 is not equal to (<>) B2.

  1. Choose any Format that you’d want to be applied to the cells that meet the above criterion. Like we are selecting a red fill.
Setting the formatting rules
  1. Press “Enter” and you get the following results.
Excel formats the cells that do not match

This time Excel has red-highlighted the cells that are different in the whole list ⭕

That’s it – Now what?

We hope you now know how to compare columns in Excel – whether to find matching items or unique items.

In the guide above, we’ve explored different functions that can help you do that. We also learned to use conditional formatting to highlight the similarities and differences between any two columns in Excel.

Excel functions and features are super versatile. Even if Excel misses out on a specific function, you can find a way to make that happen by tweaking some other Excel functions.

There are just so many functions in Excel to explore. And once you know them all – there’d be barely anything in Excel you couldn’t do 💪

Want to begin learning them? We suggest you start with the VLOOKUP function, SUMIF, and IF functions of Excel.

My 30-minute free email course teaches all details about these (and other) functions of Excel. Click here to sign up now.

Frequently asked questions

To check if two cells (say Cell A1 and B1) have the same text in Excel, apply the IF function as follows:

= IF (A1=B1, “Same Text”, “Not Same”)

If both the cells have duplicate values, the IF function would return “Same text”. And if there is some difference between both the cells, it will return “Not Same”.

To compare two lists (Say Column A and B) in Excel, apply the IF Function in a cell in Excel as follows:

= IF (A1=B1, “Same”, “Different”)

Drag and drop this formula to the whole list. The IF function will return “Same” for each row of the list that is the same in both columns and “Different” if it’s different.

Kasper Langmann2023-01-11T20:44:56+00:00

Page load link

Понравилась статья? Поделить с друзьями:
  • Compare changes in word
  • Compare cells excel if
  • Compare cell in excel
  • Compare and contrast one word
  • Comparative word form examples