Retain only one instance of a duplicate in a sheet

  • Hi,

    I have 6 tabs in my sheet. In column A of these sheets are parts codes/identifiers. I want a macro that will look in tabs 2 and 3 down column A for duplicates.


    If two duplicates exist in the SAME sheet it should delete one of them (the whole row). If one or more duplicates in column A in tab 2 are also in tab 3 it should delete ALL duplicate rows in tab 2 and keep just one in tab 3.


    I'd like this to happen separately with tabs 4, 5 & 6. So, any duplicates across these 3 tabs in column A it should delete the row THEN keep only the entry in the higher tab.


    Example,


    Bob is listed twice in column A of tab 4, 3 times in tab 5 and twice in tab 6. The macro would delete all entries in the lower tabs (4 & 5) and then delete the duplicate in tab 6 to leave just one unique entry across the 3 tabs in the highest tab number. I can post a sample workbook if it helps.

  • Re: Retain only one instance of a duplicate in a sheet


    See if this is what you wanted

  • Re: Retain only one instance of a duplicate in a sheet


    After going back to work and with new data I have spotted a problem Jindon. The tabs hmwk1 and hmwk2 should be treated separately to the 1's, 2's and 3's tabs.


    So if there is a duplicate in hmwk1 and hmwk2 keep one copy in the highest tab (hmwk2.)
    If there is a duplicate in 1's, 2's or 3's keep ONE duplicate in the highest of these tab numbers.
    This means that there could be a duplicate in hmwk1 or hmwk2 when compared to the 1's 2's or 3's tabs, as these 2 sets of tabs are treated as separate entities.


    I think your code is treating all 5 tabs in the same way so if there is a duplicate in say hmwk1 and 2's it is deleting the one in hmwk1 when it should be keeping both.


    Hope this makes sense.

  • Re: Retain only one instance of a duplicate in a sheet


    Do you mean like this?

  • Re: Retain only one instance of a duplicate in a sheet


    This is looking good. I will continue to test and feed back if needed. Thanks a lot - you are very skilled.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!