KutoolsforOffice — One Suite. Five Tools. Get More Done.

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

AuthorXiaoyangLast modified

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.

a screenshot of aligning duplicates in two columns

Compare methods for matching values in two columns

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


Compare methods for matching values in two columns

The methods below solve slightly different matching tasks. The formula and VBA methods return matching values in an aligned output column, while Kutools for Excel is designed to quickly identify and highlight matching cells directly in the compared ranges. Choose the method according to the result you need.

MethodBest forOutputKey consideration
FormulaCreating an aligned list of matches that can update with the source dataReturns matching values in a separate columnRequires a relatively long MATCH / INDEX formula and filling it down
VBA codeAutomating the creation of an aligned matching columnInserts a new column containing matching valuesRequires VBA and the code shown here assumes the compared columns are adjacent
Kutools for ExcelQuickly identifying and highlighting matching values without formulas or codeSelects and optionally highlights matching cells in the original dataReady-to-use comparison controls with optional background or font highlighting
Recommendation: Use the formula when you specifically need a dynamic aligned list of matching values, or VBA when you want to automate that output with code. If your main goal is to quickly compare two columns and identify the matching cells, Kutools for Excel provides the more convenient approach. Its Select Same & Different Cells feature avoids formulas and VBA, and can select and visually highlight the matches directly in the worksheet.

Align duplicates or matching values in two columns with formula

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:

a screenshot of using formula to align duplicates in two columns

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


Quickly find 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 without using formulas.

a screenshot of using Kutools for Excel to find matching values in two columns

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


Align duplicates or matching values in two columns with VBA code

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:

a screenshot of the original data and the duplicates aligning between two columns

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 letter of your data. Your two columns must be adjacent.

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


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

If you want to quickly identify matching values rather than create a separate aligned list, Kutools for Excel's Select Same & Different Cells feature provides a straightforward solution. It can compare two selected ranges, select matching cells, and optionally apply a background or font color to make the matches easy to see.

After installing Kutools for Excel, please do as follows:

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

a screenshot of enabling the Select Same & Different Cells feature

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

a screenshot of configuring the Select Same & Different Cells dialog box

3. Click OK, and the matching values are selected and highlighted according to your settings. See screenshot:

a screenshot showing duplicates are highlighted

Download and free trial Kutools for Excel Now!


Best Office Productivity Tools

🤖Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions…
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |  Round without Formula ...
Super Lookup: Multiple Criteria VLookup  |   Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |  Big Formula Bar   |  Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells   |  Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets:  12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


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!

All Kutools add-ins. One installer

Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.

ExcelWordOutlookTabsPowerPoint
  • All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
  • One installer, one license — set up in minutes (MSI-ready)
  • Works better together — streamlined productivity across Office apps
  • 30-day full-featured trial — no registration, no credit card
  • Best value — save vs buying individual add-in