SOLVED

Removing all values that appears more than once Leave ONLY one Unique

%3CLINGO-SUB%20id%3D%22lingo-sub-2338741%22%20slang%3D%22en-US%22%3ERemoving%20all%20values%20that%20appears%20more%20than%20once%20Leave%20ONLY%20one%20Unique%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2338741%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20Team%2C%3C%2FP%3E%3CP%3EHow%20can%20I%20remove%20just%20a%20single%20cell%20duplicate%20without%20affecting%20whole%20rows%20for%20duplicate%20value.%20Below%20is%20an%20example%20of%20what%20I%20need.%20I%20have%20also%20attached%20an%20excel%20file.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22TuM_29_0-1620552129091.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279344iF6305AD2CD4D17F0%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22TuM_29_0-1620552129091.png%22%20alt%3D%22TuM_29_0-1620552129091.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22TuM_29_1-1620552203437.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279345iA549BC8316B1F1CF%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22TuM_29_1-1620552203437.png%22%20alt%3D%22TuM_29_1-1620552203437.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2338741%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2338779%22%20slang%3D%22en-US%22%3ERe%3A%20Removing%20all%20values%20that%20appears%20more%20than%20once%20Leave%20ONLY%20one%20Unique%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2338779%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20so%20much%2C%20this%20is%20helpful%20.....%20Now%20I%20need%20to%20be%20familiar%20with%20Macro%20for%20sure%20%3Afolded_hands%3A%3Afolded_hands%3A%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2338760%22%20slang%3D%22en-US%22%3ERe%3A%20Removing%20all%20values%20that%20appears%20more%20than%20once%20Leave%20ONLY%20one%20Unique%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2338760%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1049013%22%20target%3D%22_blank%22%3E%40TuM_29%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20is%20a%20macro%20that%20you%20can%20run%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-visual%22%3E%3CCODE%3ESub%20ClearDuplicates()%0A%20%20%20%20Dim%20r%20As%20Long%0A%20%20%20%20Dim%20m%20As%20Long%0A%20%20%20%20Dim%20v%20As%20Variant%0A%20%20%20%20Application.ScreenUpdating%20%3D%20False%0A%20%20%20%20m%20%3D%20Range(%22A%3AB%22).Find(What%3A%3D%22*%22%2C%20SearchOrder%3A%3DxlByRows%2C%20SearchDirection%3A%3DxlPrevious).Row%0A%20%20%20%20v%20%3D%20Range(%22A1%3AB%22%20%26amp%3B%20m).Value%0A%20%20%20%20For%20r%20%3D%20m%20To%203%20Step%20-1%0A%20%20%20%20%20%20%20%20If%20v(r%2C%201)%20%3D%20v(r%20-%201%2C%201)%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20v(r%2C%201)%20%3D%20%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20v(r%2C%202)%20%3D%20%22%22%0A%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20Next%20r%0A%20%20%20%20Range(%22A1%3AB%22%20%26amp%3B%20m).Value%20%3D%20v%0A%20%20%20%20Application.ScreenUpdating%20%3D%20True%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
New Contributor

Hello Team,

How can I remove just a single cell duplicate without affecting whole rows for duplicate value? I have more than 160,000 rows, with a lot of those duplicates. Below is an example of what I need. I have also attached an excel file, I am using 365.

TuM_29_0-1620552129091.png

 

TuM_29_1-1620552203437.png

 

2 Replies
best response confirmed by TuM_29 (New Contributor)
Solution

@TuM_29 

Here is a macro that you can run:

Sub ClearDuplicates()
    Dim r As Long
    Dim m As Long
    Dim v As Variant
    Application.ScreenUpdating = False
    m = Range("A:B").Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    v = Range("A1:B" & m).Value
    For r = m To 3 Step -1
        If v(r, 1) = v(r - 1, 1) Then
            v(r, 1) = ""
            v(r, 2) = ""
        End If
    Next r
    Range("A1:B" & m).Value = v
    Application.ScreenUpdating = True
End Sub

@Hans Vogelaar 

Thank you so much, this is helpful ..... Now I need to be familiar with Macro for sure