Consulting

Results 1 to 5 of 5

Thread: Keep 1 Record every 5 duplicate

  1. #1
    VBAX Newbie
    Joined
    May 2010
    Posts
    4
    Location

    Keep 1 Record every 5 duplicate

    Hi

    i have a large database with a lot of duplicates
    i need to keep 1 record for each 5 duplicate.
    example if i have 2 to 9 duplicate keep 1
    if i have 10 to 14 keep 2
    if i have 15 to 19 keep 3
    if i have 61 record keep 12, etc..

    can anyone help please.
    thank you

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    It depends on how many columns you take into account before you call something a duplicate.
    If it's only one column, then you can add a formula such as:
    =MIN(COUNTIF(A$2:A2,A2),MAX(1,INT(COUNTIF($A$2:$A$76,A2)/5)))
    in column B then use Excel's built in Remove Duplicates looking at just columns A and B.
    See attached where the formula's been applied but the Remove Duplicates hasn't.
    Better to attach a workbook with a bit more detail and what you expect the result to be.
    Attached Files Attached Files
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Newbie
    Joined
    May 2010
    Posts
    4
    Location
    Thank you for your reply.
    actually i have 4 columns to be counted
    i have attached a sample of the data, and on the right the result.

    thank you again
    Regards
    Aziz
    Attached Files Attached Files

  4. #4
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    Delete column E entirely.
    In the new column E (no merged cells) in cell E2:
    =MIN(COUNTIFS(A$2:A2,A2,B$2:B2,B2,C$2:C2,C2,D$2:D2,D2),MAX(1,INT(COUNTIFS($A$2:$A$46,A2,$B$2:$B$46,B2,$C$2:$C$46,C2,$D$2:$D$46,D2)/5)))
    copy down.
    Remove Duplicates using all 5 columns.
    Delete column E.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  5. #5
    VBAX Newbie
    Joined
    May 2010
    Posts
    4
    Location
    Thank you so much, it worked.
    Regards
    Aziz

Posting Permissions

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