+ Reply to Thread
Results 1 to 17 of 17

Deleting Duplicates Based off Rejection Date

  1. #1
    Registered User
    Join Date
    06-18-2019
    Location
    USA
    MS-Off Ver
    2010
    Posts
    6

    Deleting Duplicates Based off Rejection Date

    I am stuck trying to figure out how to delete duplicates based off of rejection date. My goal is to delete rod serial number repeats if and only if the rejection date is within 24 hours of each other and to save the first rejection of the duplicates.

    For example if rod "123" gets reject at 10:00am and at 10:10am on Monday then it would delete the 10:10am entry. If rod "234" get rejected at 10:00am on Wednesday and 2:30 on Friday it would not delete either of them.

    I have been trying to do this using VBA but I am new and struggling. I hope this is descriptive enough!

    Thanks

    DeletingDuplicates.PNG

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Deleting Duplicates Based off Rejection Date

    Welcome to the forum!

    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    06-18-2019
    Location
    USA
    MS-Off Ver
    2010
    Posts
    6

    Re: Deleting Duplicates Based off Rejection Date

    Thanks for the info, is this better?
    Attached Files Attached Files

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Deleting Duplicates Based off Rejection Date

    That's great thanks, I'll have a look

  5. #5
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Deleting Duplicates Based off Rejection Date

    Question, rows 3 and 6 have the exact same date/time, but you kept one of them in the "After" example
    I think I'm missing a detail here.

    My logic was this (correct me where I went wrong... based on the rod ending in 152)

    Row 8 is the latest, so we start there.
    -Row 7 deleted because it is within 24 hrs of row 8.
    -Row 6 deleted because even though row 7 is gone, the time for the original row 7 was within 24 hrs of row 6 (or do I just delete 7 and keep comparing to row 8???)
    -Row 3 deleted because it was the same time as row 6 (which has since been deleted)

  6. #6
    Registered User
    Join Date
    06-18-2019
    Location
    USA
    MS-Off Ver
    2010
    Posts
    6

    Re: Deleting Duplicates Based off Rejection Date

    I must apologize I meant to keep the first reject. Meaning you would keep row 3. I see how it can be confusing since row 3 and 6 are the same.

    Keep row 4
    Keep row 5
    Delete 6 since it is an exact duplicate of 1
    Delete 7 since it is within in 24 hours (happens to be exactly 24 hours later)
    Keep 8 since it is over 24 hours since the first rejection

  7. #7
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Deleting Duplicates Based off Rejection Date

    So if 6 is deleted, 7 is compared to 1 because 6 no longer exists correct?

    And since 8 is kept... If the list were longer, we would start comparing to 8 not 1?

  8. #8
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Deleting Duplicates Based off Rejection Date

    Hi !

    Question : is the real workbook has worksheet row #1 with "Before" ?
    As it's very not difficult to attach a workbook sample respecting the real layout …

  9. #9
    Registered User
    Join Date
    06-18-2019
    Location
    USA
    MS-Off Ver
    2010
    Posts
    6

    Re: Deleting Duplicates Based off Rejection Date

    Yes, I would like every duplicate to be compared to the initial entry until then next duplicate is later then 24 hours then start comparing to it.
    Last edited by JCosso; 06-18-2019 at 02:41 PM.

  10. #10
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Deleting Duplicates Based off Rejection Date


    So your result is wrong ‼

  11. #11
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Deleting Duplicates Based off Rejection Date

    Give this a try:

    Please Login or Register  to view this content.
    Last edited by Arkadi; 06-18-2019 at 02:58 PM. Reason: It was updated to use the latest non-deleted date/time value for a serial number.

  12. #12
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Deleting Duplicates Based off Rejection Date


    I have a shorter way in mind but now it's dinner time, so later I will post a demonstration …

  13. #13
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Deleting Duplicates Based off Rejection Date

    Make sure what you use for testing matches my post above... I had misunderstood a detail, and while the original post worked on sample data, it would not work on longer lists.

    @ Marc L, look forward to your post as always

  14. #14
    Registered User
    Join Date
    06-18-2019
    Location
    USA
    MS-Off Ver
    2010
    Posts
    6

    Re: Deleting Duplicates Based off Rejection Date

    It does work thank you! but I wasn't clear answering one of your question. I said for it to always reference the initial entry but after thinking about that it doesn't make sense. If the next reject happens after 24 hours it should then change to reference that new reject.

    After playing around with your code I noticed it references the initial entry, my mistake. Is there a way to make that correction?

  15. #15
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Deleting Duplicates Based off Rejection Date

    Please Login or Register  to view this content.
    is what I added in my update to my post. That part means that if the row we check is from an existing serial, but the date/time is over 24 hours, then we start using the new value instead of the first one. That's why I had posted right below it that you need to make sure you use my updated post (post #11). I have added a note to that post just now to clarify that.

  16. #16
    Registered User
    Join Date
    06-18-2019
    Location
    USA
    MS-Off Ver
    2010
    Posts
    6

    Re: Deleting Duplicates Based off Rejection Date

    Awe yes that is it! Works great! This is the first time I have used this forum and now I am hooked. Thank you very much

    Also looking forward to what Marc L has to show us!

  17. #17
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Try this demonstration ‼


    Quote Originally Posted by Marc L View Post
    So your result is wrong ‼
    Sorry for that as I didn' t see the day change …


    According to the attachment just with a sort & worksheet functions - Excel basics ! - as a beginner starter :

    PHP Code: 
    Sub Demo()
         
    Dim V
             Application
    .ScreenUpdating False
        With Sheet1
    .Range("A3", [B2].End(xlDown)).Columns
            
    .Sort .Cells(1), xlAscending, .Cells(2), , xlAscendingHeader:=xlNo
            
    .Item(3).Value2 = .Parent.Evaluate("IFERROR((" & .Item(1).Address "=" & .Item(1).Offset(-1).Address _
                                            
    ")*(INT(" & .Item(2).Address ")=INT(" & .Item(2).Offset(-1).Address ")),0)")
            .
    Resize(, 3).Sort .Cells(13)
             
    Application.Match(1, .Item(3), 0)
             If 
    IsNumeric(VThen .Rows(":" & .Rows.Count).Clear
            
    .Item(3).Clear
        End With
             Application
    .ScreenUpdating True
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 06-18-2019 at 10:02 PM. Reason: typo …

+ 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] Deleting rows based on date
    By NullSpot in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 02-06-2018, 04:35 AM
  2. Deleting Data Outside of a Date Range W/ Duplicates
    By rehnwil in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-06-2016, 08:27 AM
  3. Macro Code - Deleting Duplicates based on same cell value and date comparison
    By Desree86 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-13-2014, 04:01 PM
  4. [SOLVED] Deleting Duplicates Based on Multiple Criteria from Multiple Columns
    By Franklic in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-09-2012, 05:31 PM
  5. [SOLVED] Deleting rows based on duplicates in one column only
    By KD70 in forum Excel General
    Replies: 8
    Last Post: 10-12-2012, 03:07 PM
  6. Deleting Duplicates-find out a way to delete duplicates
    By sighlent1 in forum Excel General
    Replies: 2
    Last Post: 04-19-2011, 10:17 AM
  7. Deleting a row based on date
    By F6Hawk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-23-2008, 10:57 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