+ Reply to Thread
Results 1 to 8 of 8

Identify duplicate rows and delete all but the most recent

  1. #1
    Registered User
    Join Date
    10-04-2012
    Location
    yorktown va
    MS-Off Ver
    excel 2007
    Posts
    7

    Identify duplicate rows and delete all but the most recent

    Good afternoon
    I’d like to introduce myself, recently retired from the military and working on a job conducting analysis of business process. Pretty good at excel but a novice at using VBA. I have a large spreadsheet with over 700 rows. I would like to identify all the duplicate rows using column “account number” and then use the “date completed” column to identify the most recent row and delete all older duplicate rows. I have used conditional formatting to identify the dups but don’t know how to sort their rows by date and delete the older ones. Think my answer is to use VBA but I haven’t done something this complex. Really could use someone’s help. I have attached a small sample of the spreadsheet I’m working with. Thanks
    Attached Files Attached Files
    Last edited by millerj64; 10-10-2012 at 03:00 PM.

  2. #2
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: Identify duplicate rows and delete all but the most recent

    If sorting Column C is ok then try the macro below on a copy of your sheet.

    Please Login or Register  to view this content.
    Last edited by WasWodge; 10-09-2012 at 05:41 PM.
    If my solution worked (or not) please let me know. If your question is answered then please remember to mark it solved

    Computers are like air conditioners. They work fine until you start opening windows. ~Author Unknown

  3. #3
    Registered User
    Join Date
    10-04-2012
    Location
    yorktown va
    MS-Off Ver
    excel 2007
    Posts
    7

    Re: Identify duplicate rows and delete all but the most recent

    Thanks for your help
    the script works great sorting and identifying the most current rows, but doesn't delete the older duplications.
    I need to isolate only the most current rows so I can analysis and report. If deleting the old dups is impossible, can the newest dups be highlighted to identify them? Any help will be appreciated. Thanks again

  4. #4
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: Identify duplicate rows and delete all but the most recent

    Sorry but your post is really confusing me as what you are stating is almost the exact opposite of what the macro actually does. Consider the attachments below.
    TEST1 is the original data, TEST2 is the result after the macro is run.

    Now if I wanted the most recent duplicate in Column E using the dates in Column C I would expect the result to be

    A 03/01/2012 AAA
    A 06/01/2012 BBB
    A 09/01/2012 CCCC

    This is what the macro gives me (my dates are in dd/mm/yyyyy but that doesn't make any difference as long as the dates are true dates)

    Please can you explain what answer you require from the data in TEST1 that is different to TEST2?????
    Attached Files Attached Files
    Last edited by WasWodge; 10-10-2012 at 02:25 PM. Reason: spacing

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Identify duplicate rows and delete all but the most recent

    Another Alternative

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    10-04-2012
    Location
    yorktown va
    MS-Off Ver
    excel 2007
    Posts
    7

    Re: Identify duplicate rows and delete all but the most recent

    Sorry for the confusion
    Your script works correctly, I had to reinstall excel and it ran perfectly
    Thanks for your help

  7. #7
    Registered User
    Join Date
    10-04-2012
    Location
    yorktown va
    MS-Off Ver
    excel 2007
    Posts
    7

    Re: Identify duplicate rows and delete all but the most recent

    Thanks for your help
    Your script worked like I needed it too

  8. #8
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: Identify duplicate rows and delete all but the most recent

    Happy you got it to work. You should also consider AB33's code as it doesn't involve sorting the column

    Edit: posted at roughly the same time as the OP's response
    Last edited by WasWodge; 10-10-2012 at 03:08 PM.

+ 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