VBA Formula or Script with a filter to Delete a Row if if Time is 30 sec. or Less

mr_ITtoyou

New Member
Joined
Mar 26, 2021
Messages
35
Office Version
  1. 2016
Platform
  1. Windows
I need some assistants with a VBA script to delete a row if the time in column H is 30 seconds or less. so if the time shows 0:00:30 or less I need to delete the row from the spreadsheet.
Thank you in advance for any help on this.



Abandon Report 6_21-21.xlsm
ABCDEFGH
2Call Start TimeCall ANIInitial Call PriorityCall Routed CSQCall SkillsFinal Call PriorityCall Abandon TimeTime to Abandon
36/21/2021 7:036263213401116/21/2021 7:040:00:36
46/21/2021 7:2624035116/21/2021 7:270:00:19
56/21/2021 7:2724035116/21/2021 7:280:00:32
66/21/2021 7:319099483636116/21/2021 7:320:00:15
76/21/2021 7:409098154507116/21/2021 7:410:00:15
86/21/2021 8:119099617837116/21/2021 8:110:00:19
96/21/2021 8:149099617837116/21/2021 8:160:01:13
106/21/2021 8:2195173580881Pre_Registration_CSQPre_Reg_SKILL16/21/2021 8:330:11:24
116/21/2021 8:3495173580888Radiology_CSQRadiology_SKILL86/21/2021 8:430:09:00
126/21/2021 8:3790976221711Radiology_CSQRadiology_SKILL16/21/2021 8:400:02:12
136/21/2021 8:4883227348341Radiology_CSQRadiology_SKILL16/21/2021 8:520:03:15
146/21/2021 8:5490946607071Radiology_CSQRadiology_SKILL16/21/2021 8:580:04:12
156/21/2021 9:189097315034116/21/2021 9:180:00:04
166/21/2021 9:189098154507116/21/2021 9:190:00:48
176/21/2021 9:376267333418116/21/2021 9:380:00:47
186/21/2021 9:3962673334181Radiology_CSQRadiology_SKILL16/21/2021 9:390:00:21
196/21/2021 9:529099966270116/21/2021 9:520:00:06
206/21/2021 9:529097315034116/21/2021 9:520:00:05
216/21/2021 9:589097315034116/21/2021 9:590:00:28
226/21/2021 9:5990967663661Radiology_CSQRadiology_SKILL16/21/2021 10:000:00:13
236/21/2021 10:105622332065116/21/2021 10:110:00:21
246/21/2021 10:266263615834116/21/2021 10:260:00:11
256/21/2021 10:266263615834116/21/2021 10:260:00:11
266/21/2021 10:349095392280116/21/2021 10:350:00:12
276/21/2021 10:389096226179116/21/2021 10:380:00:26
286/21/2021 10:5790960036918Radiology_CSQRadiology_SKILL86/21/2021 11:010:04:13
RSA Abandoned Call Detail Activ



Chip
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
How about this:

VBA Code:
Sub timecheck()

    Dim rng As Range, i As Long, tm As Long
    
    Application.ScreenUpdating = False
    Set rng = Range("H3:H" & Cells(Rows.Count, 8).End(xlUp).Row)
    For i = rng.Cells.Count To 1 Step -1
        tm = CSng(Replace(Format(rng.Formula(i, 1), "h:mm:ss"), ":", ""))
        If tm <= 30 Then
            rng.Cells(i).EntireRow.Delete
        End If
    Next
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0
Solution
How about this:

VBA Code:
Sub timecheck()

    Dim rng As Range, i As Long, tm As Long
   
    Application.ScreenUpdating = False
    Set rng = Range("H3:H" & Cells(Rows.Count, 8).End(xlUp).Row)
    For i = rng.Cells.Count To 1 Step -1
        tm = CSng(Replace(Format(rng.Formula(i, 1), "h:mm:ss"), ":", ""))
        If tm <= 30 Then
            rng.Cells(i).EntireRow.Delete
        End If
    Next
    Application.ScreenUpdating = True
   
End Sub
Thank you igold, for your help. That worked great.
Have a great day.
 
Upvote 0
You're welcome. I was happy to help. Thanks for the feedback!
 
Upvote 0

Forum statistics

Threads
1,215,517
Messages
6,125,290
Members
449,218
Latest member
Excel Master

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