How to remove repeating time intervals?

Waimea

Active Member
Joined
Jun 30, 2018
Messages
465
Office Version
  1. 365
Platform
  1. Windows
17:58:282020-08-02LocationDim LevelCHANGE
17:57:092020-08-02xOffOn to Off
17:06:452020-08-02xOnOn
16:45:362020-08-02xOffOn to Off
08:15:032020-08-02xOnOn
02:43:522020-08-02xOffOff
02:33:502020-08-02xOffOn to Off
02:05:032020-08-02xOnOn
01:05:022020-08-02xOffOff
00:56:452020-08-02xOffOff
00:28:452020-08-02xOffOff
00:05:022020-08-02xOffOff
23:05:032020-08-01xOffOff
18:09:302020-08-01xOffOff
16:43:462020-08-01xOffOn to Off
08:15:032020-08-01xOnOn
03:49:462020-08-01xOffOff
03:46:092020-08-01xOffOn to Off
02:05:022020-08-01xOnOn
01:05:022020-08-01xOffOff
00:05:032020-08-01xOffOff
23:05:022020-07-31xOffOff
23:00:032020-07-31xOffOff
17:16:502020-07-31xOffOff
17:16:502020-07-31xOffOff


Hi, I have time data and I want to remove reapeating time intervals, at 02:05:03, at 01:05:02 etc. It could also be 23:05:13 et.

The minute is always 05 but the hour and the seconds varies but I still want to remove the corresponding rows.

I also want to delete multiple Off to Off in the change column. If the change column has Off, Off, Off I want to remove the corresponding rows.

If you have any questions, I'll try to answer as best as I can.

Grateful for your assistance!

I am looking for a VBA solution!


02:05:03​
 
Last edited by a moderator:
Hi again,

thank you for your reply.

I think your code deletes all the "Off to Off"?

If there are 3 "Off to Off" next to each other I want to remove 2 of them. If there are 2, I want to remove 1 of them.

If there are 5 "Off to Off" I want to delete 4 of them, leaving the last one on top.
 
Upvote 0

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
VBA Code:
Sub RemoveAll()
    'Remove 05s
    On Error Resume Next
    lr = Range("A" & Rows.Count).End(xlUp).Row
    For i = lr To 1 Step -1
        If Minute(Range("A" & i)) = 5 Then
            Range("A" & i).EntireRow.Delete
        End If
    Next i
    
    'Remove Offs
    lr = Range("E" & Rows.Count).End(xlUp).Row
    For i = lr To 2 Step -1
        If Range("E" & i).Value = "Off to Off" And Range("E" & i - 1).Value = "Off to Off" Then
            Range("E" & i).EntireRow.Delete
        End If
    Next i
End Sub
 
Upvote 0
Solution
Hi iggydarsa,

thank you for your help and for your code.

The last code is great and you nailed it, solved it, aced it! :)
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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