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 combine two lists without duplicates in Excel?

There are two lists in your worksheet, and some of values in the lists are duplicates, and you want to combine these two lists and just leave the unique values, as shown as the below screenshots, how can you do?

Combine lists without duplicates with Remove Duplicates in Excel

Combine lists without duplicates with VBA

Combine lists without duplicates with Kutools for Excel


arrow blue right bubble Combine lists without duplicates with Remove Duplicates in Excel


To combine two lists and remove duplicate values in Excel, you can do as follow:

1. Copy one of the two lists and paste it to the bottom of the other list, see screenshot:

2. Select the list and click Data > Remove Duplicates, see screenshot:


3. In the Remove Duplicates dialog, if your column has no header, uncheck My data has headers, and then click OK. See screenshot:


4. Then a dialog displays on the screen to tell you the duplicates have been delete, click OK. See screenshot:


You can see the result:



arrow blue right bubble Combine lists without duplicates with VBA

In Excel, a VBA also can help you combine the two lists without duplicates.

1. Hold ALT button and press F11 on the keyboard to open a Microsoft Visual Basic for Application window.

2. Click Insert > Module, and copy the VBA into the module.

VBA: Combine lists without duplicates

Sub FindUniques()
'Updateby20140313
Dim rng As Range
Dim InputRng As Range, OutRng As Range
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)
Set OutRng = Application.InputBox("Out put to (single cell):", xTitleId, Type:=8)
Set dic = CreateObject("Scripting.Dictionary")
For j = 1 To InputRng.Columns.Count
    For i = 1 To InputRng.Rows.Count
        xValue = InputRng.Cells(i, j).Value
        If xValue <> "" And Not dic.Exists(xValue) Then
            OutRng.Value = xValue
            dic(xValue) = ""
            Set OutRng = OutRng.Offset(1, 0)
        End If
    Next
Next
End Sub

 

3. Click Run button or press F5 to run the VBA.

4. A dialog displayed on the screen, and you can select the range you want to combine. See screenshot:


5. Click OK, then another dialog popped up for you to select a cell to output the combined result. See screenshot:


6. Click OK. You can see the lists have been combined.


Tip: The result cannot reserve the cells formatting after running the above VBA.


arrow blue right bubble Combine lists without duplicates with Kutools for Excel

With installed Kutools for Excel, you can use the Select duplicates & unique cells function to solve the problem that combine two list without duplicates.

Kutools for Excel includes more than 300 handy Excel tools. Free to try with no limitation in 30 days. Get it Now

1. Copy one of the two lists and paste it to the bottom of the other list, select the new list, then click Kutools > Select Tools > Select duplicates & unique cells. See screenshot:


2. In the Select duplicates & unique cells dialog, check All uniques (Including 1st duplicates), click Ok.


3. Then a dialog pops up to tell you how many unique values have been selected, click OK and Cancel to close two dialogs. See screenshot:


4. And copy the selected unique values and paste them to a new column. See screenshot:


Click here to know more about Select duplicates & unique cells.


Relative Articles:

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.

Be the first to comment.