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!
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.
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)
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
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 …
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.
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?
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.
Bookmarks