+ Reply to Thread
Results 1 to 14 of 14

Delete of duplicate records

  1. #1
    Registered User
    Join Date
    10-23-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    34

    Delete of duplicate records

    Hey guys,

    I'm having trouble getting this piece of macro to work. I want to delete duplicate Id records in (Cell B12 : B124), but only those with "No" in the (Cell Z12 : Z124) will be deleted.

    Table
    B12 Z12
    -------------
    E1 Yes
    E2 Yes
    E3 Yes
    E4 Yes
    E1 No
    E2 No
    E3 No
    E4 No

    Expected results:
    E1 Yes
    E2 Yes
    E3 Yes
    E4 Yes

    Please Login or Register  to view this content.
    I was just wondering if it is possible to automatically delete duplicate records within the worksheet, even without using of a macro button.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Delete of duplicate records

    without macro
    just auto filter on column z=no
    then delete rows
    oops misread post
    instead
    in another spare column say col aa
    in aa12
    put
    =countif ($b$12:$b$124,b12)>1 and drag down to aa124
    select range a12:aa124 and apply auto filter
    filter on
    1 aa12:aa124 =true
    then
    2. z12:z124 =no
    delete rows
    Last edited by martindwilson; 11-22-2009 at 11:41 AM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    10-23-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Delete of duplicate records

    I might be easier to just use a macro that delete duplicate entries without having to always filter and delete.
    Last edited by ChalkerL; 11-22-2009 at 12:41 PM.

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Delete of duplicate records

    er no! that took me about 30seconds!

  5. #5
    Registered User
    Join Date
    10-23-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Delete of duplicate records

    Hm.. But I'm actually creating this worksheet for another user, hence it might be easier with a macro button.
    Last edited by ChalkerL; 11-22-2009 at 01:05 PM.

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Delete of duplicate records

    when do you want it to delete duplicates?
    you could probably use that so it runs on work workbook open or before close and making sure it runs in thisworkbook and specified sheet

  7. #7
    Registered User
    Join Date
    10-23-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Delete of duplicate records

    Ok, then is there anyway i can display only 6 results.

    I know that excel has this function where you display the top 10 results, but that is by the highest number of the cell. instead i want it to display top 6 results based on Cell Z being Yes then No, and not duplicates of the ID which is Cell B.

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Delete of duplicate records

    sorry i dont understand! how can you have top 6 when criteria is yes/no or do you mean only the first 6.

  9. #9
    Registered User
    Join Date
    10-23-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Delete of duplicate records

    If you dont mind looking at my excel, it is under shortlisted admin.

    I'm actually trying to display the top 6 results.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    10-23-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Delete of duplicate records

    Sorry. I meant displaying only the first 6.

    Currently i have sorted Cell Z in descending order. So the Yes would appear before the no.

    And i want to display the first 6 results only.

  11. #11
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Delete of duplicate records

    which are the first 6 you want? not saying i can do it tho!
    but if your code generates the non duplicate list then simply copy the first six
    to another sheet. its geting too deep intp vba for me tho
    Last edited by martindwilson; 11-22-2009 at 01:44 PM.

  12. #12
    Registered User
    Join Date
    10-23-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Delete of duplicate records

    Hmm .. Thanks.

    All the worksheet is currently sorted based on the cell Z with the Yes being the main priority, then the No.

    Cause if the Yes doesn't display the No will automatically go up based on the filter.

    So with the listing that has been sorted, I'm trying to display only the first 6 after the sorting.

  13. #13
    Registered User
    Join Date
    10-23-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Delete of duplicate records

    but if your code generates the non duplicate list then simply copy the first six
    but it's hard to capture the cell number cause the cell number would jumble up after sorting. So it's hard to predict which cells to copy

  14. #14
    Registered User
    Join Date
    10-23-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Delete of duplicate records

    Can i incorporate your code into my formula

    Please Login or Register  to view this content.
    At the end, i check for duplicates

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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