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

or

How to align duplicates or matching values in two columns in Excel?

doc align duplicates 1

If you have two list of names, and you want to compare these two columns and find the duplicates in both, and then align or display the matching names based on the first column in a new column as following screenshot shown. To list the duplicate values which exist in both columns, this article may introduce some tricks for solving it.

Align duplicates or matching values in two columns with formula

Align duplicates or matching values in two columns with VBA code

Find and highlight the duplicates or matching values in two columns with Kutools for Excel


Align duplicates or matching values in two columns:

Kutools for Excel's Select Same & Different Cells feature can help you quickly select and highlight the same or different cells from two columns.

doc align duplicates 7

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!



Here is a simple formula which can help you to display the duplicate values from two columns. Please do as this:

Enter this formula: =IF(ISNA(MATCH(A2,$C$2:$C$12,0)),"",INDEX($C$2:$C$12,MATCH(A2,$C$2:$C$12,0))) into a blank cell which beside your first column, B2, for example, then drag the fill handle down to the cells that you want to apply this formula, and all the values both in column A and column C have been aligned with the matching values in column A , see screenshot:

doc align duplicates 2

Note: In the above formula, A2 is the first cell value of the column which you want to compare, and C2:C12 another column data that you want to be compared with. You can change the cell references to your need.


Supposing you have two adjacent columns- column E and column F which have some duplicate names, with the following code, a new column will be inserted between these two columns and the duplicate values are listed as below screenshot shown:

doc align duplicates 3

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

VBA code: Align duplicates or matching values in two columns

Sub Listduplicates()
'Updateby Extendoffice 20160613
    Dim rngA As Range
    Set rngA = Range([E1], Cells(Rows.Count, "E").End(xlUp))
    rngA.Offset(0, 1).Columns.Insert
    With rngA.Offset(0, 1)
        .FormulaR1C1 = _
        "=IF(ISNA(MATCH(RC[-1],C[1],0)),"""",INDEX(C[1],MATCH(RC[-1],C[1],0)))"
        .Value = .Value
    End With
End Sub

Note: In the above code, E1 is the first cell in your first compared column, and E indicates the first column letterof your data. And your two columns must be adjacent.

3. Then press F5 key to run this code, after executing the code, a new column will be inserted between these two columns, and the duplicate values both in the two columns are aligned based on the first matching values.


If you have Kutools for Excel, with its Select Same & Different Cells function, you can quickly compare the data in two columns and select the duplicate cells in one column. What’s more, you can shade a background color or font color for the duplicates.

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days. 

After installing Kutools for Excel, please do as follows:

1. Hold Ctrl key to select the two data columns separately, and then click Kutools > Select Same & Different Cells, see screenshot:

doc align duplicates 4

2. In the Select Same & Different Cells dialog box, check My data has headers if you don’t want the headers to be compared, and then select Each row under the Based on section, and select Same Values from the Find section, at the same time, you can fill a background or font color for the duplicate values under the Processing of results section. See screenshot:

doc align duplicates 5

3. Then click Ok button, and the duplicate values both in column A and in column B have been selected and highlighted in Column A as following screenshot shown:

doc align duplicates 6

Download and free trial Kutools for Excel Now !


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!


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
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.
    Isha · 9 months ago
    I had a huge volume of data and all the columns were misaligned , your formula helped a lot.! Kudos
    I tried searching everywhere and wasn't satisfied but you nailed it:) Keep up the good work.
    - Esha
  • To post as a guest, your comment is unpublished.
    Sanjiv · 1 years ago
    How can we match 2 no of column with similar data example- column A (WB40 C 4212), Column B (4212)
  • To post as a guest, your comment is unpublished.
    Kaya · 2 years ago
    Thank you for the help! Made my job easier. Keep up the great work.
  • To post as a guest, your comment is unpublished.
    Ayanda · 2 years ago
    Hi, I just wanted to say...Thank you very much, all the way from South Africa