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

Kutools for Excel: add 120 new features in Excel. Save one hour every day.
Classic Menu for Office: brings back classic menus to Office 2010 and 2013 (includes Office 365).
Office Tab: brings tabbed interface to Office as the use of web browser Chrome, Firefox and Internet Explorer.

arrow blue right bubbleFind duplicate values in two columns with Formula

Hot
Amazing! Using Tabs in Excel like Firefox, Chrome, Internet Explore 10!

Look at the following screenshot, I have column A (A1:A15) and column C (C1: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 B1, input this formula: =IF(ISERROR(MATCH(A2,$C$1:$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.

You can click here to know more about this feature.

Related Article:

How to find unique values between two columns in excel?


Kutools for Excel

More than 120 Advanced Functions for Excel 2013, 2010, 2007 and Office 365.

screen shot

btn read more     btn download     btn purchase

Comments  

+2#Dorai Kannah2013-10-24 08:00
Great Work Guys!!!
Thanks for the help!!
Reply | Reply with quote | Quote
+2#Bob Dole2013-10-31 16:30
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!
Reply | Reply with quote | Quote

Add comment


Security code
Refresh