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 Excel


arrow blue right bubbleFind 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-duplicates1

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-duplicates2

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-duplicates3


arrow blue right bubbleFind 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-duplicates4

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

doc-find-duplicates5

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

doc-find-duplicates6

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


arrow blue right bubbleQuickly 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 Excel add-ins, free to try with no limitation in 30 days. Get it Now

After installing Kutools for Excel, please click Kutools > Compare Ranges.

doc-find-duplicates7

1. In the Compare Ranges dialog box, click the first doc-replace-range-names-7button to select the source column to be compared. And click the second doc-replace-range-names-7button to select the column you are compared with. Then choose Same Values from Rules section. See screenshot:

doc-find-duplicates8

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

doc-find-duplicates9

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

Click to know more about this Compare Ranges feature.

Free Download Kutools for Excel Now


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

Comments  

Permalink +10 Dorai Kannah
Great Work Guys!!!
Thanks for the help!!
2013-10-24 08:00 Reply Reply with quote Quote
Permalink +7 Bob Dole
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!
2013-10-31 16:30 Reply Reply with quote Quote
Permalink +2 Praveen
Saved me a lot of time. Great work.

Thanks a lot for your blog post.
2014-06-25 01:51 Reply Reply with quote Quote
Permalink +1 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.
2014-08-04 18:56 Reply Reply with quote Quote
Permalink 0 Wilson
Quoting 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.


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
2014-08-27 02:33 Reply Reply with quote Quote
Permalink +1 Alex789
I had the same problem (only formula displaying) and F2 fixed it. Thanks, this is such a time saving and brilliant solution.
2015-02-03 05:48 Reply Reply with quote Quote
Permalink 0 Simen H
It works perfect here. You might need to change the , to ; if you havent already done that :)
2014-09-04 13:31 Reply Reply with quote Quote
Permalink +1 Stby
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
2014-09-12 17:04 Reply Reply with quote Quote
Permalink 0 JOEL
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?
2014-10-01 17:23 Reply Reply with quote Quote
Permalink 0 There is another way
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.
2016-08-04 22:51 Reply Reply with quote Quote
Permalink 0 SUDHEEP
Thaanks a lot..it worked!!!
Initially it didn't work for me. I followed Stby 's suggestion and it worked..
2014-09-17 12:48 Reply Reply with quote Quote
Permalink 0 Martin
I get a bunch of TRUE and FALSE, not the actual Number
2014-09-26 16:57 Reply Reply with quote Quote
Permalink 0 JOEL
Used Formula to find Duplicates in two Columns, worked fine, But now it will not. It acts as if both columns require same format? Didn't before. Please HELP,,,
2014-10-01 17:05 Reply Reply with quote Quote
Permalink 0 Umar
What is the meaning or purpose of dollar sign ($)in excel?
2014-10-14 11:06 Reply Reply with quote Quote
Permalink 0 Ankit
One of the best shortcuts available on the internet to compare two excel columns.
2014-11-04 15:43 Reply Reply with quote Quote
Permalink 0 JP
I am trying to acknowledge the duplicates within 2 columns. Each column contains about 12000 account #'s and I have to determine which ones are duplicate from the previous year. Any ideas?
2014-11-06 19:48 Reply Reply with quote Quote
Permalink 0 CC
This article shows how to highlight duplicate values across a number of columns, however it is looking for duplicate values within each column. I was hoping to highlight cells when the value in the 1st cell in column 1, equals the value in the 1st cell in column 2, and the same all the way down. So if A5=B5 I want it to be highlighted, but not highlight if A5=B6, and not highlight if A5=A6. I hope that makes sense. Is there a way to do this?
2014-12-04 00:13 Reply Reply with quote Quote
Permalink 0 Dominic
Hi,
This works only if the values are numeric... But does not if the value is alphabets or alpha numeric - Any other alternatively?
2015-03-04 17:10 Reply Reply with quote Quote
Permalink 0 xprexweb
greats WORK gUY greats WORK gUY
2015-04-17 17:52 Reply Reply with quote Quote
Permalink 0 AMS
Hi
when you paste it paste it without any format or formula (paste as value)
2015-04-29 14:14 Reply Reply with quote Quote
Permalink 0 Tan
Thanks a lot it saved my manual search time !!lot of time!!Copy & paste works but when i enter formula by myself it is not working any clue.
2015-06-03 08:27 Reply Reply with quote Quote
Permalink 0 Sanjay Kumar
i want some information regards, Excel Formula A Unique No and B amount c date d date, i want see that whenever i do applying formula pick unique no and calculation should on date C AND d column add value
2015-07-13 11:39 Reply Reply with quote Quote
Permalink 0 Keith
In your first formula, is there a way to make the names in column C turn red if nothing in Column A matched?
2015-08-10 13:25 Reply Reply with quote Quote
Permalink 0 Gopi
Thank you very much.
2015-08-20 04:16 Reply Reply with quote Quote
Permalink 0 JOP
Hello!
Does not work for Excel 2013! nor using fill down.
I used F2 and Enter,
2015-10-20 19:59 Reply Reply with quote Quote
Permalink 0 Vikas
How to Check Name Two Column with Duplicate?
2015-10-26 08:01 Reply Reply with quote Quote
Permalink -1 Rick
Hello,
Is there any way to match & pair duplicates in two separate columns? Example: There are 6 identical search items being searched for and only four identical amounts in the column being searched.
The match function finds the 1st duplicate in the column being searched and then returns the ordinal location of that 1st match position for each subsequent duplicate it finds in the search column.
Is there any way to identify duplicate matched items & define their distinct ordinal position with the column being searched.
This way if there are six duplicate search item amounts and only four duplicates found in the "Search Column" only the four items in the "Search Column" are matched and paired with the items searched.
I hope I have explained myself clearly and would like to thank you in advance for any help you may be able to offer on the subject.

Kind Regards,
RWF
2015-11-15 19:03 Reply Reply with quote Quote
Permalink 0 Carlos Ferreira
THANK YOU VERY MUCH.
2016-02-05 16:25 Reply Reply with quote Quote
Permalink 0 Summer
Hi, I need a bit of help. I tried the VBA method and received the following error message: "Compile error. Invalid outside procedure".

Any advice would be greatly appreciated, thanks
2016-03-22 08:02 Reply Reply with quote Quote
Permalink 0 Nike
I'm trying to compare values on two columns on the same spreadsheet. Where there are duplicates, that is fine. However, where the values differ, I want the contents of one of the columns to be replaced with that of the other column. How do I go about that?


Thanks.
2016-03-26 12:46 Reply Reply with quote Quote
Permalink 0 NISHIT
HOW CAN I COMPAIR WHOL TWHO COLUMN TO FIND DUPLICAT VALUE
2016-08-11 06:15 Reply Reply with quote Quote
Permalink 0 Bhaskar
How to find common value in A1 : S1
2016-09-01 12:28 Reply Reply with quote Quote
Permalink 0 Matt
When copy =IF(ISERROR(MAT CH(A2,$C$2:$C$1 3,0)),"",A2) make sure take off the full stop at the end or it will not work.
2016-10-05 15:08 Reply Reply with quote Quote
Permalink 0 Taher
Hi. I have a question ... please help me.
We have two sheets. In one of theme, there are names and another one ,address. Some names do not have address. And the addresses and names are irregular. And only with the code We can link theme to each other. I want to do something that names and addresses sort by the code.
sorry for my ENGLISH
An example of sheets:
Sheet 1:
name code
2111 David

Second sheet:
address code
st ... 2020
st6 2025
st .. 2111
2016-11-05 09:58 Reply Reply with quote Quote
Permalink 0 Vijay
Taher... Send me your Email ID. I can help you. What i understand that you have 2 sheets. One has names and some Code for each name and the second one has Addresses and Codes. The Code is the only column which can connect these 2 sheets. And you want all the names and their corresponding addresses to be displayed based on Codes.

Please send the same question to my email id . I can send you the script and tell you the steps how it works.

Regards
Vijay
2016-11-07 07:20 Reply Reply with quote Quote
Permalink 0 RITESH
its good...thnq u




..
2016-11-18 06:49 Reply Reply with quote Quote
Permalink 0 Sobuj Prantor
that was really great.
2016-12-05 07:03 Reply Reply with quote Quote
Permalink 0 Shameer
Thank You Very Much Guys
2016-12-20 09:05 Reply Reply with quote Quote

Add comment


Security code
Refresh