+ Reply to Thread
Results 1 to 10 of 10

Remove Duplicates Based on other column Specific Value

  1. #1
    Registered User
    Join Date
    12-30-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    16

    Remove Duplicates Based on other column Specific Value

    Hi there,
    I am new to this forum. Could you please help me with my issue to delete duplicate records based on other column specific Text? I have searched in so many ways but I couldn’t find a solution for my problem.

    I have a macro found in this forum which is very useful to remove duplicates except first instance of Duplicates from Column “C”.
    I need a macro which keeps one instance and remove other duplicates based on Other Column text value. In my case I need to keep either Cricket or Football from column “E” as a 1st instance and rest of all items should be deleted from Duplicates list. If none of the Duplicates have Cricket or Football in Column “E” needs to keep any value as 1st instance and remove the other duplicates.
    Please find the attached excel spreadsheet having my current Macro which removes duplicates except 1st instance based on Column C.
    1st tab having sampl data and second tab having the result what I am looking for.
    I have arranged duplicates in a Sorting Order in Column C to understand easily. My actual project doesn’t have values in a sorting order.
    Thanks in advance
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    05-28-2019
    Location
    Newport
    MS-Off Ver
    365
    Posts
    30

    Re: Remove Duplicates Based on other column Specific Value

    Im a bit confused with what you are trying to get here. looking at your dataset there is no fixed result unless you add additional columns with what you want to keep.

    looking at the code, this is correct. I would say the issue here is the order you have your data.
    perhaps modify the macro to sort the data before removing duplicates.

    looking what i would do, i would sort by sport type, then country, then remove duplicates.
    Last edited by mario_berry; 05-14-2021 at 01:27 PM.

  3. #3
    Registered User
    Join Date
    12-30-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    16
    Quote Originally Posted by mario_berry View Post
    Im a bit confused with what you are trying to get here. looking at your dataset there is no fixed result unless you add additional columns with what you want to keep.

    looking at the code, this is correct. I would say the issue here is the order you have your data.
    perhaps modify the macro to sort the data before removing duplicates.

    looking what i would do, i would sort by sport type, then country, then remove duplicates.
    Hi Mario, thank you for your reply. Is it possible for you to provide an updated macro to solve my issue. Iam not good at writing Macros as Iam basic learner. I want to do the sorting and removal of duplicates through macro only. Please help me. Much appreciated.

  4. #4
    Registered User
    Join Date
    05-28-2019
    Location
    Newport
    MS-Off Ver
    365
    Posts
    30

    Re: Remove Duplicates Based on other column Specific Value

    what sort do you want

    how would you sort the table that is

  5. #5
    Registered User
    Join Date
    12-30-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    16
    Quote Originally Posted by mario_berry View Post
    what sort do you want

    how would you sort the table that is
    I mean removing duplicates through macro only..
    First instance should contains either cricket or football is my primary requirement. If duplicates doesn't contain cricket or football, remove duplicates except 1st instance.
    Sorry for my bad english.

  6. #6
    Registered User
    Join Date
    05-28-2019
    Location
    Newport
    MS-Off Ver
    365
    Posts
    30

    Re: Remove Duplicates Based on other column Specific Value

    The below is the code to sort by sport type, then sort by country.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-28-2019
    Location
    Newport
    MS-Off Ver
    365
    Posts
    30

    Re: Remove Duplicates Based on other column Specific Value

    don't be sorry for bad English, id have said it was good.

    ok, this is going to mix things up a bit.
    firstly, i would want to highlight the values you want to keep. i would do this by adding a column with a formula.

    =IF(OR(E2="Cricket",E2="Football"),"Keep","")

    The above highlights the values you want to keep.

    Secondly, i would modify the VBA i posted earlier to sort the additional column.

    Please Login or Register  to view this content.
    you will notice i have changed the second sort to descending, this is otherwise the ones you dont want to keep will be at the top.

  8. #8
    Registered User
    Join Date
    12-30-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    16

    Re: Remove Duplicates Based on other column Specific Value

    Hi Mario, your code helps me to understand the logic. But I found one issue relating to my project with your code. Is it possible to remove duplicates without Sorting the data in Sport (E) and Country (C) Columns .
    As I am getting an issue while Sorting values. For example from the Duplicates List for the Country POLAND the result value should be Football. But due to sorting issue its showing "Chess" instead of Football.

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Remove Duplicates Based on other column Specific Value

    Try
    Please Login or Register  to view this content.
    Last edited by jindon; 05-15-2021 at 07:34 AM.

  10. #10
    Registered User
    Join Date
    12-30-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    16

    Re: Remove Duplicates Based on other column Specific Value

    Thank You Jindon. Your code Exactly What I am looking for.
    Thank you Mario Your code also doing the same but in different method. I like the methods you shown with a Formula and sorting features will help in my project work.
    Appreciated both of you Jindon & Mario.
    Thanks to Excelforum as this is my first post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 03-18-2021, 09:10 AM
  2. Remove duplicates based on other column.
    By domcindor in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-16-2019, 06:13 AM
  3. Remove duplicates based on other column.
    By domcindor in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-13-2019, 10:07 AM
  4. [SOLVED] Remove duplicates based on specific words
    By coatesy69 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-26-2016, 08:23 AM
  5. remove duplicates based on name found in column b
    By antiKILLER in forum Excel General
    Replies: 2
    Last Post: 03-01-2016, 02:57 PM
  6. Replies: 5
    Last Post: 05-08-2014, 07:24 AM
  7. remove entire row based on duplicates from single column
    By mikemeadeuk in forum Excel General
    Replies: 2
    Last Post: 10-15-2011, 02:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1