+ Reply to Thread
Results 1 to 9 of 9

Code to Remove Duplicates from Rows but Retain Latest Record

  1. #1
    Forum Contributor
    Join Date
    06-25-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016
    Posts
    615

    Code to Remove Duplicates from Rows but Retain Latest Record

    Hi Folks

    I require Code to remove complete rows from Col I that are duplicates.
    However I need to retain the latest record of each.

    Example Workbook attached.

    Cheers
    hammer
    Attached Files Attached Files
    If you have found solving my problem/s to be an interesting and educational exercise then how about Repping me up?
    No idea why I need Rep, other than feeling left out....

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Code to Remove Duplicates from Rows but Retain Latest Record

    First google search yielded this
    http://www.mrexcel.com/forum/excel-q...ast-entry.html

    you only needed to change the column reference from 1 to 9
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Code to Remove Duplicates from Rows but Retain Latest Record

    • Sort on the dates descending in column C so the most recent are first
    • Use the Remove Duplicates function to delete duplicate rows and keep the first occurrence.
    • Sort the dates ascending in column C to return them they way they were.

    These three steps can be recorded in a macro.
    Last edited by AlphaFrog; 05-02-2016 at 03:03 AM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Forum Contributor
    Join Date
    06-25-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016
    Posts
    615

    Re: Code to Remove Duplicates from Rows but Retain Latest Record

    @humdingaling
    Thanks for the pointer- my problem is, whilst I can search for similar Code I never know how to adjust it to suit my specific requirement. I am the original Dummy- the one they wrote books for

    @AlphaFrog
    These simple steps prove what I just stated above- I am a Dummy

    Thanks to you both for replying-
    Cheers
    hammer

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Code to Remove Duplicates from Rows but Retain Latest Record

    Try this
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  6. #6
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Code to Remove Duplicates from Rows but Retain Latest Record

    @ Hammer

    i'm guessing you didnt finish the dummies guide then

    http://www.dummies.com/how-to/conten...-2016-vba.html

  7. #7
    Forum Contributor
    Join Date
    06-25-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016
    Posts
    615

    Re: Code to Remove Duplicates from Rows but Retain Latest Record

    Thanks to YasserKhalil for the Code

    Correct hummer.... I'm a Dummy at everything

  8. #8
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Code to Remove Duplicates from Rows but Retain Latest Record

    You're welcome. Glad I can offer some help
    Thanks for the feedback and for rep points

  9. #9
    Registered User
    Join Date
    10-15-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    22

    Re: Code to Remove Duplicates from Rows but Retain Latest Record

    Hello, I have the same problem but my question is, how can add this code to an existing code?

    Thanks in advance,
    Cris

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro to locate, remove duplicates, but keep latest date
    By dawilburn67 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-10-2014, 03:34 PM
  2. Code to remove duplicates and organize rows.
    By Nitefox in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-15-2014, 07:23 AM
  3. [SOLVED] Retain Order but Remove Duplicates
    By ssjagger in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-05-2014, 08:02 AM
  4. Remove duplicate address rows but retain spouse name
    By dsrinssyb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-24-2013, 03:57 PM
  5. Replies: 5
    Last Post: 02-21-2013, 11:37 AM
  6. Remove duplicates but keep the one with latest date
    By nee2m in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-21-2012, 10:09 AM
  7. inserting / remove rows and retain formatting
    By task in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-23-2009, 02:24 AM

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