Compare cell in excel

When you have a lot of data in a spreadsheet it becomes quite difficult to compare the contents of two cells without just staring closely into the screen.

Moreover, if your data pans over a large number of rows, it can be quite annoying to compare data in cells that are quite far apart.

In this tutorial we will show you how to compare two cells in Excel, in different cases:

  • When you want to compare for an exact match (case insensitive)
  • When you want to compare for an exact match (case sensitive)
  • When you want to display a defined value for a match or no match
  • When you want to compare for a partial match
  • When you want to compare numeric values in the cells

How to Compare Two Cells for an Exact Match (Case Insensitive)

This method is probably the quickest way to compare two cells in Excel (for equality).

The formula used in this method is really simple, involving only a comparison operator, in this case, the ‘equal to’ operator.

Say you have two values in cells B1 and B2, and you want to find out if they are an exact match or not.

dataset to compare two cells

Simply type the following formula to return a TRUE (if they match) or FALSE (if they don’t).

=B1=B2

Please note that this formula does not consider whether the contents of the cells are in upper or lowercase. Both are considered the same.

If the contents of both cells match exactly (irrespective of case), the formula returns a TRUE. Else, it returns a FALSE.

Formula to compare two cells

How to Compare Two Cells for an Exact Match (Case Sensitive)

If you want an exact match, including the case of the text, then you should use the EXACT function instead of the comparison operator.

The EXACT function takes two strings and checks for an exact match, including whether the text is in upper or lower case.

The syntax for the function is simple:

=EXACT(text1, text2)

Here, text1 and text2 are the two strings that we want to compare.

The function compares the two strings and returns a TRUE value if there is an exact match (including case), and FALSE if there isn’t.

In the following example, the EXACT function returns a FALSE, since the strings in cells B1 and B2 don’t match (although both cells have the same text, the value in B1 starts with an uppercase letter, while the one in B2 starts with a lowercase letter).

EXACT formula to compare two cells

How to Display a Defined value for a Match or No Match

The above two methods simply return a TRUE or FALSE value after testing for a match.

However, someone else looking at your worksheet might not be able to understand what you mean by TRUE or FALSE.

So you might want to return a more descriptive value if there’s a match.

Moreover, you might want to display some specific text for a match in some cases.

For example, you might want to display the text ‘Winning’ if values in cells B1 and B2 are equal. If not then you can probably display “Not winning”, or something like that.

For this, you can use the IF function as follows:

=IF(B1=B2,"Winning","Not winning")

The above formula uses the IF function to compare values in B1 and B2. If the condition “B1=B2” is TRUE, the function returns the text “Winning”. If not, it returns the text “Not winning”.

IF function to compare cells

For an exact match (including case), you can use the formula:

=IF(EXACT(B1,B2),"Winning","Not winning")
IF formula with Exact to compare two cells

If you don’t necessarily need an exact match, you can also check for a partial match between two cells.

For example, you might want to see if the last few digits of a phone number or the first few digits of an ID are the same.

To compare the first n digits, you can use the following formula:

=LEFT(string1,n)=LEFT(string2,n)

So, for example, if you want to compare the first 2 digits of values in B1 and B2, then n=2, and your formula will be:

=LEFT(B1, 2) = LEFT(B2, 2)
Compare part of a cell with another cell

Similarly, to compare the last n digits, you can use the following formula:

=RIGHT(string1,n)=RIGHT(string2,n)

So, for example, if you want to compare the last 3 digits of values in B1 and B2, then n=3, and your formula will be:

=RIGHT(B1, 3) = RIGHT(B2, 3)
Compare substring of two cells

Note: If you want an exact match of the first n digits (including case), then you can wrap an EXACT function around the LEFT or RIGHT functions as follows:

=EXACT(LEFT(B1, 2),LEFT(B2,2))
EXACT with LEFT formula to compare two cells

You can also compare two cells to see if the value in one of them exists in the other.

This can be achieved using wildcard characters like ‘*’ or ‘?’. For example, consider the following pair of values:

Wildcard to compare two cells

Let’s say you want to check if the two values (in B1 and B2) match partially (one of the values exists as a part of the other value).

The formula for this is a little more complex since you will need to consider cases where the first value is smaller than the second and vice-versa:

=IF(LEN(B1)<LEN(B2),IFERROR(MATCH("*"&B1&"*",B2:B2,0)>0,FALSE),IFERROR(MATCH("*"&B2&"*",B1:B1,0)>0,FALSE))
Formula to compare partial strings in two cells

Explanation of the Formula

Let us break down this formula and analyze it part by part:

LEN(B1)<LEN(B2)

We want to know if there is a partial match between values in B1 and B2. This means, that if the string in B1 is shorter than the string in B2, then we want to know if B1 exists in B2.

Similarly, if it’s the other way round, we want to find out if the value in B2 exists in B1.

To find out which string is shorter, we simply compare the lengths of the two strings using the LEN function.

MATCH(“*”&B1&”*”,B2:B2,0)>0

If the string in B1 is shorter than that of B2, then we want to check if the string of B1 is a part of the string in B2.

The MATCH function here checks if the value in B1 exists as a part of B2 (using the asterisk wildcard).

If it does, then the MATCH function returns the position of the matching string in B2. If it does not exist in B2, then the function returns a 0.

But we just want to know whether the value exists in B2 or not. We don’t really care about the position. So, we simply check if the value returned is more than 0.

If it is, that means that the value in B1 is a part of the value in B2. We got a partial match.

The only problem is that if there is no match, the MATCH function returns an #N/A error. To keep this in check, we can simply wrap an IFERROR function around this formula, like this:

IFERROR(MATCH(“*”&B1&”*”,B2:B2,0)>0,FALSE)

So now if the value in B1 does not exist in B2, the IFERROR function simply returns a FALSE.

In the same way, if the string in B2 is shorter than that of B1, then we want to check the other way round.

We simply exchange cell references B1 and B2, so the third parameter (of the main IF function) is specified as:

IFERROR(MATCH(“*”&B2&”*”,B1:B1,0)>0,FALSE)

To sum up, in the above formula, we simply use the IF function to compare LEN(B1) and LEN(B2). If the string in B1 is shorter, the function returns IFERROR(MATCH(“*”&B1&”*”,B2:B2,0)>0,FALSE).

Otherwise, it returns IFERROR(MATCH(“*”&B2&”*”,B1:B1,0)>0,FALSE)

Let us try this on a few sample pairs of strings to see if the formula actually works in all cases:

Checking in content of one cell is there in another

As we can see, the formula compares the two values in each column and returns a TRUE whenever there is a partial match, and a FALSE when there’s no match.

How to Compare Two Cells to Find the Larger or Smaller Number

Finally, let us see a case where you have numeric values in two different cells and you want to compare them to see if one of them is larger than the other.

For example, the following dataset contains pairs of values in rows 1 and 2, and we want to find out which value is larger.

Compare cells with numbers

The formula you can use is as follows:

=IF(B1>B2,B1,B2)
IF formula to compare two cells

If you just want to know if the value in B2 is larger than the one in B1, then your formula will be:

=B2>B1
Simple arithmetic formula to compare cells

In this tutorial, we showed you how to compare two cells in a variety of cases.

We tried to cover as many comparison possibilities as we could think of. We hope from the cases we mentioned here you were able to find what you needed.

Other Excel tutorials you may also find helpful:

  • How to Compare Two Columns in Excel (using VLOOKUP & IF)
  • Find the Closest Match in Excel (Nearest Value) – Easy Formula
  • How to Paste in a Filtered Column Skipping the Hidden Cells
  • How to Compare Dates in Excel (Greater/Less Than, Mismatches)
  • How to Compare Two Excel Sheets (for differences)
  • How to Hide Rows based on Cell Value in Excel
  • ‘Does Not Equal’ Operator in Excel (Examples)

Aside from staring at them closely, how can you compare two cells in Excel? Here are a few functions and formulas that check the contents of two cells, to see if they are the same.

Easy Way to Compare Two Cells

To compare the two cells, we’ll start with a simple check, then try more complex comparisons.

  • Tip: You can see more ways to compare two cells on my Contextures site. Get an Excel workbook with all the examples from that page too.

The quickest way to compare two cells is with a formula that uses the equal sign.

  • =A2=B2

If the cell contents are the same, the result is TRUE. (Upper and lower case versions of the same letter are treated as equal).

Compare Two Cells Exactly

If you need to compare two cells for contents and upper/lower case, use the EXACT function. This video shows a few EXACT examples.

As its name indicate, the EXACT function can check for an exact match between text strings, including upper and lower case.

The EXACT function doesn’t test the formatting though, so it won’t detect if one cell has some or all of the characters in bold, and the other cell doesn’t.

  • =EXACT(A2,B2)

See more EXACT function examples on my Contextures site.

comparecells09

Partially Compare Two Cells

Sometimes you don’t need a full comparison of two cells – you just need to check the first few characters, or a 3-digit code at the end of a string.

To compare characters at the beginning of the cells, use the LEFT function. For example, check the first 3 characters:

  • =LEFT(A2,3)=LEFT(B2,3)

To compare characters at the end of the cells, use the RIGHT function. For example, check the last 3 characters, and combine with the EXACT function:

  • =EXACT(RIGHT(A2,3),RIGHT(B2,3))

How Much Do Cells Match?

Finally, here’s a formula from UniMord, who needed to know how much of a match there is between two cells. What percent of the string in A2, starting from the left, is matched in cell B2?

Here’s a sample list, where three formulas check the addresses in column A and B, and calculate the percent that the characters match.

comparecells01

Get the Text Length

The first step in calculating the percent that the cells match is to find the length of the address in column A. This formula is in cell C2:

  • =LEN(A2)

Get the Match Length

Next, the formula in column D  finds how many characters, starting from the left in each cell, are a match. Lower and upper case are not compared.

  • =SUMPRODUCT(
    –(LEFT(A3,
    ROW(INDIRECT(“A1:A” & C3)))
    =LEFT(B3,
    ROW(INDIRECT(“A1:A” &C3)))))

Tip: If you’re using Excel 365, there’s a shorter formula you can use, with one of the new Spill functions. See the new formula on the Compare Two Cells page of my Contextures site.

How It Works

Here’s a quick overview of how the formula works, and there are detailed notes on the Compare Two Cells page of my Contextures site

  1. INDIRECT and ROW functions create an array of numbers, from 1 to X
  2. Left X characters from the two cells are compared, using equal sign
  3. Comparison returns TRUE or FALSE
  4. Two minus signs, near the start of the formula, converts TRUE and FALSE to ones and zeros
  5. SUMPRODUCT function adds up numbers. In row 5, total is 1

comparecells07

Get the Percent Match

The final step is to find the percent matched, by dividing the two numbers:

  • =D2/C2

There is a 100% match in row 2, and only a 20% match, starting from the left, in row 5.

comparecells01

Thanks, UniMord, for sharing your formula to compare two cells, character by character.

Get the Compare Cells Sample File

You download an Excel workbook with all the examples, and see more ways to compare two cells on my Contextures site. The sample workbook is in xlsx format, and does not contain any macros.

That page also has details on how the Percent Matched formulas work, and there’s a shorter version of the Percent Matched formula, if you’re using Excel 365.

More Ways to Compare Two Cells

Here are a few more articles that show examples of how to compare two cells – either the full content, or partial content.

  • Use INDEX, MATCH and COUNTIF to find codes within text strings. There are other formulas in the comments too, so check those out.
  • Compare formulas on different sheets, with the FORMULATEXT and INDIRECT functions. Those functions are volatile though, so they’d slow down the workbook if you use too many of them.
  • Be careful when using the Remove Duplicates feature in Excel – it treats real numbers and text numbers as the same value

__________________________

Compare 2 Cells in Excel

___________________

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.

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)

Compare two Columns in Excel

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.

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

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

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

Letusunderstandthesemethods 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.

How do you compare two cells in Excel?

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.

    How do you compare two cells in Excel?

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

    How do you compare two cells in Excel?

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

    How do you compare two cells in Excel?

  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.

    How do you compare two cells in Excel?

#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 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.

How do you compare two cells in Excel?

#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 functionEXACT 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.

How do you compare two cells in Excel?

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.

How do you compare two cells in Excel?

#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 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.

How do you compare two cells in Excel?

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

How do you compare two cells in Excel?

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.

How do you compare two cells in Excel?

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

How do you compare two cells in Excel?

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.

How do you compare two cells in Excel?

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.

How do you compare two cells in Excel?

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 Excel
  • Excel Rows to Columns
  • Count Only Unique Values in Excel
  • Advanced Filter in Excel

All in One Excel VBA Bundle (35 Courses with Projects)

  • 35+ Courses
  • 120+ Hours
  • Full Lifetime Access
  • Certificate of Completion

LEARN MORE >>

Понравилась статья? Поделить с друзьями:
  • Comparative word form examples
  • Comparative and superlative forms of the word easy
  • Comparative and superlative forms of the word cheap
  • Comparative and superlative forms for the word good
  • Comparative and superlative degree of word little