+ Reply to Thread
Results 1 to 6 of 6

Duplicate Based on Multi-Coulmn - Only Keep the Earliest and Latest Value

  1. #1
    Registered User
    Join Date
    10-27-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    13

    Question Duplicate Based on Multi-Coulmn - Only Keep the Earliest and Latest Value

    Below is an example of an Excel sheet I'm working with:

    Excel-Duplicates.png
    http://i.stack.imgur.com/KKHkF.png

    Basically, I'm trying to delete the duplicate rows by matching ID, Date and Type. If ID, Date and Type are the same, then, I want to only keep the record with the earliest Time in case of Type = In and the latest Time in case of Type = Out.

    So, for example, in the case of ID = 1, there are 3 records for In, I only want to keep the one where Time is: 8:01 as this is the earliest. The other 2 records should be deleted.

    Similarly, in the case of ID 3, I want to keep the record where Time = 18:05 as this is the later time out of the 2.

    Can this be achieved by Conditional Formatting or Macro or VBA?

    Many thanks for your help in advance.
    Last edited by jturner12; 03-18-2014 at 09:41 AM. Reason: Image for attachment

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,864

    Re: Duplicate Based on Multi-Coulmn - Only Keep the Earliest and Latest Value

    1) by conditional formatting you wil not delete any dupes you can only highlight them.
    2) macro could of course do this.
    3) one can probably add a column(s) with formula and then autofilter or delete duplicates on this
    4) one picture is worth 100 words, but on this forum one workbook is worth 100 pictures - attach a sample workbook (see in forum rules how).

    simple sample ;-) solution (based on p.3 above):
    in I2 formula: =A2&E2
    in J2 formula: =IF(E2="Out",1-D2,D2)
    (you can format output as time if you wish) and copy botch cells down
    Select all data and these 2 extara columns and sort data (use sort dialog) on these 2 columns (both ascending)
    From Data ribbon -> Remove Duplicates (using only column I)
    delete helper columns.
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    10-27-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Duplicate Based on Multi-Coulmn - Only Keep the Earliest and Latest Value

    hi kaper,

    Many thanks for your reply. I have attached a sample Spreadsheet. I will try your suggestion.

    If there are any more suggestions for achieving this I would be grateful.

    Thank You once again

    Duplicates_Time.xls

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Duplicate Based on Multi-Coulmn - Only Keep the Earliest and Latest Value

    Try this
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-27-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Duplicate Based on Multi-Coulmn - Only Keep the Earliest and Latest Value

    Many Thanks Jindon, that seems to be working perfectly

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Duplicate Based on Multi-Coulmn - Only Keep the Earliest and Latest Value

    You are welcome and thanks for the rep.

    It will be easier and shorter, if the data always sorted by the time.

    I considered when it is not sorted so a little complex....

+ 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. Looking Up Earliest and Latest Time Values
    By warhead92100 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 10-25-2013, 06:07 AM
  2. Getting the earliest and latest date in Pivot Table
    By dluhut in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-02-2013, 01:54 PM
  3. Earliest and Latest Time where cell contains certain text
    By asalbus in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-23-2013, 01:45 AM
  4. Extracting earliest and latest prices in excel
    By rsecomak in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-05-2012, 11:22 AM
  5. Earliest and Latest Dates from a list of names?
    By TimMatrix in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-21-2008, 07:34 PM

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