+ Reply to Thread
Results 1 to 5 of 5

Removal of duplicates, with conditions.

  1. #1
    Registered User
    Join Date
    01-02-2012
    Location
    Melbourne
    MS-Off Ver
    Excel 2003
    Posts
    63

    Removal of duplicates, with conditions.

    Hi

    I was wondering how I can get rid of all duplicates, and yet have control over which remaining entry I want to keep.

    Attached is the file and as well as a screenshot

    Thank you in advance

    http://i.imgur.com/J65WLZR.png
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    10-10-2012
    Location
    New York
    MS-Off Ver
    Excel 2007/2010
    Posts
    337

    Re: Removal of duplicates, with conditions.

    Okay, this is a bit of a multi-step process based on the fact you just want the records with the most fields (read: columns) filled in.
    1) insert a blank row above your data.
    2) in cell G2 put =A2&B2 and copy down
    3) in cell H2 put =COUNTA($A2:$F2) and copy down
    4) in cell I2 put =IF($G2=$G1,"",INDEX($A$2:$G$9,MATCH($G2,$G$2:$G$9,0),MATCH(A2,$A2:$G2,0))) copy across for all the fields you need (in this case over to column N), and down
    5) Now you need to highlight all this data starting in row 2 and do a sort. Sort by column G(Ascending) then by column H(Descending). click Sort.
    6) You should now have only those records for unique combinations of column A & B with the records with the most fields filled in.
    7) Copy everything in columns I:N and paste special values on another sheet.
    8) Do another sort on this data and you have what you need.

    Please let me know if this is works for you and if any of these steps need clarification.

    I welcome anyone else who has a more elegant solution as I would love to see it.
    Don't just use the answers provided for you. Try to understand how it works by reverse engineering or asking about it.

    Please mark the thread as [SOLVED] (Thread Tools->Mark thread as Solved) when answered.
    If you're happy with an answer given, please click the * under the person's name to boost their reputation.

  3. #3
    Registered User
    Join Date
    01-02-2012
    Location
    Melbourne
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Removal of duplicates, with conditions.

    Thank You Craig, it worked a treat!!

  4. #4
    Valued Forum Contributor
    Join Date
    10-10-2012
    Location
    New York
    MS-Off Ver
    Excel 2007/2010
    Posts
    337

    Re: Removal of duplicates, with conditions.

    Thanks for the feedback. I was racking my brain trying to think of a one-and-done formula and remembered not everything needs/can be solved in one step.

    Cheers

  5. #5
    Registered User
    Join Date
    01-02-2012
    Location
    Melbourne
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Removal of duplicates, with conditions.

    as an FYI..

    I got the exact same result by only employing a couple of the steps. I did:

    - COUNTA then i sorted the results in descending order
    - then removed duplicates
    - copy and pasted special values in another sheet

    I ran a test on both results and found it was the same.

    My spreadsheet is 20,000 rows long. The 'cleansed' spreadsheets now each contain 5,478 rows.

    To further test each spreadsheet, i concatenated all 6 cells of results (per row), then i added (LEN) the amount of characters in the concatenated cell (they were large values, like 120-150, so the chances of getting a similar number were quite slim). I then subtracted one value from the other. If it was a zero then i simply deduced it was the same entry (post duplicate removal). I then added all the differences and the total was ...zero.

    I dont know if it qualifies as a more elegant solution. Its simply a watered down (possibly less robust?) solution to the one you presented.

    Thanks again Craig
    Last edited by Rob8489; 06-07-2013 at 10:11 AM. Reason: typos

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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