Working with Date using macro

Babalola

New Member
Joined
Feb 26, 2018
Messages
13
Occurence Time Recovery Time
2/25/201816:24

<tbody>
</tbody>
2/25/201818:14
2/25/201813:542/25/201815:24
2/25/201810:092/25/201811:24
2/25/2018 7:242/26/201816:24
2/25/2018 11:242/26/201812:24
2/26/201816:242/26/201816:24
2/26/201816:242/26/201816:24
2/26/201816:242/26/201816:24

<tbody>
</tbody>


if i have such table and i need to delete issues that occur on a particular day and recovers on same day e.g ( issues that started on 2/25/2018 7:24 and recover on 2/25/201818:14. leaving issues that started on 2/25/201818:14 and recovers on 2/26/2018 and also issues that started on 2/26/2018 and recovers on 2/26/2018 with the use of macro
****** id="cke_pastebin" style="position: absolute; top: 0px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">
2/26/201816:24

<tbody>
</tbody>
2/26/201816:24

<tbody>
</tbody>
2/25/201818:14

<tbody>
</tbody>
2/25/201818:14

<tbody>
</tbody>
2/25/201818:14

<tbody>
</tbody>
</body>
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
You'd need to identify your range you're looking to clean up. Then, loop from the bottom to the top identifying which rows to delete. In VBA, you can use the DateDiff function to determine the days between the and resolved times.

I'm a bit confused on why you'd leave issues from Feb 26 that are resolved on the same day.

If we only keep rows where the two dates fall on different calendar days:
Code:
Sub RemoveSome()
Dim rng As Range
Dim i&


Set rng = [A2:B9]
For i = rng.Rows.Count To 1 Step -1
    If DateDiff("d", rng(i, 1), rng(i, 2)) = 0 Then rng(i, 1).EntireRow.Delete
Next i


End Sub
 
Upvote 0
tell whoever creates this report to create dates and not strings... also the formats are inconsistent... if things will be inconsistent your macro will have to check what situation it is dealing with and then do something different...your example will have to parse from strings for most of em then two it can use as a date... hard to write code for sloppy reports :)

these are dates... the rest are strings...

2/25/2018 7:24
2/25/2018 11:24
 
Last edited:
Upvote 0
tell whoever creates this report to create dates and not strings... also the formats are inconsistent... if things will be inconsistent your macro will have to check what situation it is dealing with and then do something different...your example will have to parse from strings for most of em then two it can use as a date... hard to write code for sloppy reports :)

these are dates... the rest are strings...

2/25/2018 7:24
2/25/2018 11:24

maybe how I copy , the report contains date... actually the Feb is just a sample
 
Upvote 0

Forum statistics

Threads
1,213,521
Messages
6,114,104
Members
448,548
Latest member
harryls

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top