i all, i have this macro below which deletes all rows from the prev day.
Sub DeleteFromDate()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim LR As Long
LR = ActiveSheet.Range("F" & Rows.Count).End(xlUp).Row
DateR = Application.InputBox("Enter based on date to delete", TitleMsg, FormatDateTime(Date, vbShortDate), Type:=1)
Cells.AutoFilter Field:=6, Criteria1:="<=" & DateR
ALR = ActiveSheet.Range("F" & Rows.Count).End(xlUp).Row
If ALR > 1 Then
Range("F2:F" & LR).SpecialCells(xlCellTypeVisible).Select
Range("F2:F" & LR).Delete
Range("F1").Activate
End If
Cells.AutoFilter
MsgBox "Finished deleting rows"
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
on my report i have it sorted on the created date and the column which details the created date and time is shown as e.g. Oct 4, 2021 7.55 PM. with the macro above it removes all rows from the previous day but what i am trying to is expand that and remove any rows that have the created date before 8.00 PM the previous day. So my daily report which i received on the 5th would show all information from the 4th backwards. but i only need the rows from the 3rd, 8.00 PM onwards.
Any help or guidance if this is possible would be greatly appreciated
thanks
Sub DeleteFromDate()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim LR As Long
LR = ActiveSheet.Range("F" & Rows.Count).End(xlUp).Row
DateR = Application.InputBox("Enter based on date to delete", TitleMsg, FormatDateTime(Date, vbShortDate), Type:=1)
Cells.AutoFilter Field:=6, Criteria1:="<=" & DateR
ALR = ActiveSheet.Range("F" & Rows.Count).End(xlUp).Row
If ALR > 1 Then
Range("F2:F" & LR).SpecialCells(xlCellTypeVisible).Select
Range("F2:F" & LR).Delete
Range("F1").Activate
End If
Cells.AutoFilter
MsgBox "Finished deleting rows"
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
on my report i have it sorted on the created date and the column which details the created date and time is shown as e.g. Oct 4, 2021 7.55 PM. with the macro above it removes all rows from the previous day but what i am trying to is expand that and remove any rows that have the created date before 8.00 PM the previous day. So my daily report which i received on the 5th would show all information from the 4th backwards. but i only need the rows from the 3rd, 8.00 PM onwards.
Any help or guidance if this is possible would be greatly appreciated
thanks