Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or
0
0
0
s2smodern

How to find duplicate values in two columns in Excel?

When we use a worksheet, sometimes we need to compare two columns and find the same values. For example, I have two long columns of student names, and now, I want to compare them and find out the same names. If I compare them cell by cell, it will be tiresome and waste a lot of time. Are there any quick ways to finish this task?

Find duplicate values in two columns with Formula

Find duplicate values in two columns with VBA code

Quickly find duplicate values in two columns with Kutools for Excelgood idea3

Quickly find duplicate values in one column with Kutools for Excelgood idea3


Compare two ranges and select and highlight the same or different values in Excel

In Excel, if there are two tables in a sheet or two sheets needed to be compared, generally, you will compare one row by one manually. But if you have Kutools for Excel's Select Same & Different Cells utility, you can quickly find the same rows or different rows, and, also, you can highlight them with background color or font color as you need. Free trial for 60-days!
doc select same difference
 
Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days.

Find duplicate values in two columns with Formula


Look at the following screenshot, I have column A (A2:A15) and column C (C2:C13) which contain some duplicate names.

doc find duplicates 1

By using a formula, we can compare two columns and display the duplicate values. Please do with the following steps:

1. In cell B2, input this formula: =IF(ISERROR(MATCH(A2,$C$2:$C$13,0)),"",A2).

doc find duplicates 2

Note: In the above formula: A2 is the column which you want to be compared. $C$2:$C$13 is the range that you want to be compared with. You can change the variables for what you are using.

2. Press the Enter key. Select cell B2, and then drag the fill handle over cell B15. And all of the duplicate names will be displayed in column B. See screenshot:

doc find duplicates 3


Find duplicate values in two columns with VBA code

The following VBA code can also help you to find out the duplicate values between two columns.

1. Click Developer > Visual Basic, a new Microsoft Visual Basic for applications window will be displayed, click Insert > Module, and input the following code into the Module:

VBA code: find duplicates from two columns

Sub Compare()
Dim Range1 As Range, Range2 As Range, Rng1 As Range, Rng2 As Range, outRng As Range
xTitleId = "KutoolsforExcel"
Set Range1 = Application.Selection
Set Range1 = Application.InputBox("Range1 :", xTitleId, Range1.Address, Type:=8)
Set Range2 = Application.InputBox("Range2:", xTitleId, Type:=8)
Application.ScreenUpdating = False
For Each Rng1 In Range1
    xValue = Rng1.Value
    For Each Rng2 In Range2
        If xValue = Rng2.Value Then
            If outRng Is Nothing Then
                Set outRng = Rng1
            Else
                Set outRng = Application.Union(outRng, Rng1)
            End If
        End If
    Next
Next
outRng.Select
Application.ScreenUpdating = True
End Sub

2. Click doc-multiply-calculation-3 button to execute the code, in the popped out box select Range 1 that you want to compare.

doc find duplicates 4

3. Click OK and go on selecting Range 2 that you will be compared with.

doc find duplicates 5

4. Then click OK, and the duplicate values both in column A and column C have been selected in column A.

doc find duplicates 6

Note: If you want to select the duplicates from column C, you just need to swap the two selected columns.


Quickly find duplicate values in two columns with Kutools for Excel

With the help of Kutools for Excel, you can find the duplicate values quickly and comfortably.

Kutools for Excel, with more than 120 handy functions, makes your jobs easier. 

After installing Kutools for Excel, please do as below:(Free Download Kutools for Excel Now!)

Click Kutools > Select > Select Same & Different Cells.

doc find duplicates 10

1. In the Select Same & Different Cells dialog box, do the following operations:

(1.) Click the first doc-replace-range-names-7button to select the source column to be compared, then click the second doc-replace-range-names-7button to select the column you are compared with;

(2.) Choose Each row under the Based on section;

(3.) Then select Same Values fromt he Find section;

(4.) At last, you can choose one background or font color to highlight the same cells under the Processing of resuts section as you need.

doc find duplicates 8

2. Then click OK, and the same values both in column A and column B have been selected in column A.

doc find duplicates 9

With this utility, you can also find the different values between two columns.


Notes:

  • My data has headers: If the data you are compared has headers, you can check this option, and the headers will not be compared.
  • Select entire rows: With this option, the entire rows which contain the same values will be selected.
  • Case Sensitive: Checking this option, you will compare the columns with case sensitive.
  • The two comparing ranges must contain the same number of columns.
  • If you want to select the duplicates from column C, you just need to swap the two selected columns.

Demo: Quickly find and highlight duplicate values in two columns

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


Quickly find duplicate values in one column with Kutools for Excel

After installing Kutools for Excel, please do as below:(Free Download Kutools for Excel Now!)

Sometimes, you may want to find the duplicate values in a column, the Kutools for Excel also can help you quickly handle it.

1. Select the column you want to find duplicate values, click Kutools > Select > Select Duplicate & Unique Cells.
doc find duplicates 11

2. In the Select Duplicate & Unique Cells dialog, check Duplicates or All duplicates option as you need, and at the same time, you can decide to highlight the duplicates with background or font color or not in Processing of results section.
doc find duplicates 12

3. Click Ok, a dialog pops out to remind you the number of selected duplicate cells, click OK to close it, and the duplicates are selected and highlighted.
doc find duplicates 13


Related Article:

How to find unique values between two columns in excel?


Recommended Productivity Tools

Office Tab

gold star1 Bring handy tabs to Excel and other Office software, just like Chrome, Firefox and new Internet Explorer.

Kutools for Excel

gold star1 Amazing! Increase your productivity in 5 minutes. Don't need any special skills, save two hours every day!

gold star1 200 New Features for Excel, Make Excel Much Easy and Powerful:

  • Merge Cell/Rows/Columns without Losing Data.
  • Combine and Consolidate Multiple Sheets and Workbooks.
  • Compare Ranges, Copy Multiple Ranges, Convert Text to Date, Unit and Currency Conversion.
  • Count by Colors, Paging Subtotals, Advanced Sort and Super Filter,
  • More Select/Insert/Delete/Text/Format/Link/Comment/Workbooks/Worksheets Tools...

Screen shot of Kutools for Excel

btn read more      btn download     btn purchase

Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Martin · 4 years ago
    I get a bunch of TRUE and FALSE, not the actual Number
  • To post as a guest, your comment is unpublished.
    SUDHEEP · 4 years ago
    Thaanks a lot..it worked!!!
    Initially it didn't work for me. I followed Stby 's suggestion and it worked..
  • To post as a guest, your comment is unpublished.
    Ian · 4 years ago
    Sadly, this didn't work for me. I have literally copied and pasted the formula, so I don't know why it didn't work.

    I have experimented with making my data text, numbers, or general.

    All I get is the formula displayed. The formula actually isn't performing its function.
    • To post as a guest, your comment is unpublished.
      There is another way · 2 years ago
      You can also use the Match function.

      Make sure to put your headers so you can also sort after
      In column A you have 1 list and in column C your 2nd list
      In B2 use Match(A:A,C:C,0) hit enter.. it won't work if your items aren't matching in what they are, like a number to a number thing
      Then using your filter function uncheck everything except the N/A in the 2nd column and you will see what isn't in the 1st.. easily knowing what didn't have matches and what did. You can do it both ways so just reverse the C and A in the above formula and see what isn't in A that is in C.. It works great for really long lists, then you don't have to continually scroll for those with and without matches.
    • To post as a guest, your comment is unpublished.
      Stby · 4 years ago
      Suggestion to Ian - when copy/pasting from a website to Excel, first copy to Notebook and then to Excel. Sometimes the formatting of the text in the website is what is screwing it up, by sending it through Notebook first you are removing any and all formatting.
      ~Stby
      • To post as a guest, your comment is unpublished.
        JOEL · 4 years ago
        I did this, but it still will not work. If I find a duplicate on my own and cut & paste that cell from column c to a. THEN the formula Shows me. ALL cells are Formatted the same. Why is it doing that?
    • To post as a guest, your comment is unpublished.
      Simen H · 4 years ago
      It works perfect here. You might need to change the , to ; if you havent already done that :)
    • To post as a guest, your comment is unpublished.
      Wilson · 4 years ago
      [quote name="Ian"]Sadly, this didn't work for me. I have literally copied and pasted the formula, so I don't know why it didn't work.

      I have experimented with making my data text, numbers, or general.

      All I get is the formula displayed. The formula actually isn't performing its function.[/quote]

      Rename(F2) the cell and press enter again for the formula to register.

      Note:remove the . at the end of the formula if there is an error
      • To post as a guest, your comment is unpublished.
        Alex789 · 3 years ago
        I had the same problem (only formula displaying) and F2 fixed it. Thanks, this is such a time saving and brilliant solution.
  • To post as a guest, your comment is unpublished.
    Praveen · 4 years ago
    Saved me a lot of time. Great work.

    Thanks a lot for your blog post.
  • To post as a guest, your comment is unpublished.
    Bob Dole · 4 years ago
    YOU MAGNIFICENT NERD YOU! I've been looking all over and every other tutorial sucks or doesn't understand that this is what people are trying to do. THANK YOU SO MUCH! And Happy Halloween! Keep up the great work!