Skip to main content

How to remove duplicates but keep rest of the row values in Excel?

In Excel, it will remove all duplicate values and move up when you apply the Remove Duplicates function as screenshot 1 shown. However, in some cases, you may want to remove duplicates but keep the rest of the row values as screenshot 2 shown. Now, in this case, I will introduce some tricks on deleting duplicates but keeping the rest in Excel.

doc remove duplicates keep rest 1 doc remove duplicates keep rest 2

Remove duplicates but keep rest of row values with Filter (3 steps)

Remove duplicates but keep rest of row values with VBA (4 steps)

Remove duplicates but keep rest of row values with Kutools for Excel (2 steps)good idea3


Remove duplicates but keep rest of row values with Filter

With a formula and the Filter function, you can quickly remove duplicates but keep rest.

1. Select a blank cell next to the data range, D2 for instance, type formula =A3=A2, drag auto fill handle down to the cells you need. See screenshot:
doc remove duplicates keep rest 3

2. Select all data range including the formula cell, and click Data > Filter to enable Filter function. See screenshot:
doc remove duplicates keep rest 4

3. Click at the Filter icon in Column D (the formula column), and check TURE from the drop down list, see screenshot:
doc remove duplicates keep rest 5

4. Click OK, and then all duplicates have been list, and select all of the duplicate values, press Delete key to remove them. See screenshot:
doc remove duplicates keep rest 6

5. Click Data > Filter to disable Filter, and remove the formulas as you need. You can see all duplicates have been removed and the rest of values are kept in the row.
doc remove duplicates keep rest 7


Remove duplicates but keep rest of row values with VBA

In Excel, there is a VBA code that also can remove duplicates but keep rest of row values.

1. Press Alt + F11 keys to display Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste below code to the Module.

VBA: Remove duplicates but keep rest of row values

Sub RemoveDuplicates()
'UpdatebyExtendoffice20160918

    Dim xRow As Long
    Dim xCol As Long
    Dim xrg As Range
    Dim xl As Long
    On Error Resume Next
    Set xrg = Application.InputBox("Select a range:", "Kutools for Excel", _
                                    ActiveWindow.RangeSelection.AddressLocal, , , , , 8)

    xRow = xrg.Rows.Count + xrg.Row - 1
    xCol = xrg.Column
    'MsgBox xRow & ":" & xCol
    Application.ScreenUpdating = False
    For xl = xRow To 2 Step -1
        If Cells(xl, xCol) = Cells(xl - 1, xCol) Then
            Cells(xl, xCol) = ""
        End If
    Next xl
    Application.ScreenUpdating = True
    
End Sub

doc remove duplicates keep rest 8

3. Press F5 key to run the code, a dialog pops out to remind you to select a range to remove duplicate values from. See screenshot:
doc remove duplicates keep rest 9

4. Click OK, now the duplicate values have been removed from selection and leave blank cells.
doc remove duplicates keep rest 10


Remove duplicates but keep rest of row values with Kutools for Excel

If you have Kutools for Excel – a handy and powerful add in tool installed, you can quickly remove duplicates but keep rest or row values through two wayss.

Kutools for Excel, with more than 300 handy functions, makes your jobs more easier. 

After installing Kutools for Excel, please do as below:(Free Download Kutools for Excel Now!)

Method 1 Merge Same Cells (2 steps)

1. Select the duplicate values, click Kutools > Merge & Split > Merge Same Cells. See screenshot:
doc remove duplicates keep rest 11

2. Then the duplicate values have been merged into one cell. And click Home > Merge & Center > Unmerge Cells to split them. See screenshot:
doc remove duplicates keep rest 12

Now the result has been shown as this:
doc remove duplicates keep rest 13

Method 2 Select Duplicate & Unique Cells (4 steps)

1. Select the list of data you want to remove duplicates from, and click Kutools > Select > Select Duplicate & Unique Cells. See screenshot:
doc remove duplicates keep rest 14

2. In the Select Duplicate & Unique Cells dialog, check Duplicates (Except 1st one) option in the Rule section. See screenshot:
doc remove duplicates keep rest 15

3. Click Ok, a dialog pops out to remind you how many duplicates have been selected, click OK to close it. See screenshot:
doc remove duplicates keep rest 16

4. Then press Delete key to remove the selected duplicate values.

doc remove duplicates keep rest 17

Tip: with Kutools for Excel’s Advanced Combine Rows utility, you can combine the duplicate values and then do some calculations on another column as below screenshot shown. It’s full function without limitation in 30 days,please download and have a free trial now.
doc remove duplicates keep rest 18

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

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

Description


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!
Comments (14)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
iNFORMATION IS VERY USEFUL.SAVED A LOT OF TIME

THANKS.
This comment was minimized by the moderator on the site
It help me after long search thank bro
This comment was minimized by the moderator on the site
Thank you so much! This was very helpful!!
This comment was minimized by the moderator on the site
i would use the formula =A3<>A2 (not equal to ) so that it show up on top vs. last one on bottom.
This comment was minimized by the moderator on the site
i tried the formula =A2=A1, it also got the result of show up on top.
This comment was minimized by the moderator on the site
i tried the formula =A1=A2, it also get the same result of show up on top
This comment was minimized by the moderator on the site
the true false really helped!
This comment was minimized by the moderator on the site
The True/False solution is a smart trick. Thanks
This comment was minimized by the moderator on the site
Is it possible to merge the like cells without the Kutools add-in?
This comment was minimized by the moderator on the site
This comment was minimized by the moderator on the site
In the first method, instead of =A3=A2, you can do =A2=A1 to keep the first instance and delete the rest of the duplicates.
This comment was minimized by the moderator on the site
yes it works
This comment was minimized by the moderator on the site
Thank you for this comment! Exactly what I was looking for!
This comment was minimized by the moderator on the site
Thank you for this tutorial, it saves me from tons of work removing duplicates.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations