SWAY14
New Member
- Joined
- Jul 27, 2022
- Messages
- 15
- Office Version
- 2019
- 2016
- 2013
- Platform
- Windows
- MacOS
Hello,
So I have VBA code that deletes rows if its not current date. Im trying to modify it to delete if timestamp is less than stated timestamp. but the issue is that it also deletes timestamps greater then the stated timestamp.
this is the code
Option Explicit
Sub testtime()
Application.ScreenUpdating = False
Dim i As Long, lr As Long, ws2 As Worksheet
Set ws2 = Sheets("Sheet2")
lr = ws2.Range("A" & Rows.Count).End(xlUp).Row
For i = lr To 2 Step -1
If ws2.Cells(i, 1).Value < ("17:00:00") Then
ws2.Cells(i, 1).EntireRow.Delete
End If
Next i
Application.ScreenUpdating = True
End Sub
this is what my table stamp time is
any suggestions or help is greatly appreciated
So I have VBA code that deletes rows if its not current date. Im trying to modify it to delete if timestamp is less than stated timestamp. but the issue is that it also deletes timestamps greater then the stated timestamp.
this is the code
Option Explicit
Sub testtime()
Application.ScreenUpdating = False
Dim i As Long, lr As Long, ws2 As Worksheet
Set ws2 = Sheets("Sheet2")
lr = ws2.Range("A" & Rows.Count).End(xlUp).Row
For i = lr To 2 Step -1
If ws2.Cells(i, 1).Value < ("17:00:00") Then
ws2.Cells(i, 1).EntireRow.Delete
End If
Next i
Application.ScreenUpdating = True
End Sub
this is what my table stamp time is
any suggestions or help is greatly appreciated