jdavis2506
New Member
- Joined
- Mar 3, 2016
- Messages
- 7
Hello,
Currently i run a weekly report that drags in the past weeks breakdowns and i am trying to find a way to delete a whole row of cells if the time is before 8AM.
I have had a number of attempts but i cant get anything to work;
Sub DeleteRows()
Dim i As Long
With Sheets("12 hr Nights")
' I want to ignore the first 7 rows
For i = .Cells(Rows.Count, "J").End(xlUp).Row To 7 Step -1
If .Cells(i, "J") < "08:00:00" Then
.Rows(i).Delete
End If
Next i
End With
End Sub
I think the problem im having is the date is in the same column as the time (01/03/2016 06:45:00). Im new to vba so any help would be appreciated.
Thanks!
Currently i run a weekly report that drags in the past weeks breakdowns and i am trying to find a way to delete a whole row of cells if the time is before 8AM.
I have had a number of attempts but i cant get anything to work;
Sub DeleteRows()
Dim i As Long
With Sheets("12 hr Nights")
' I want to ignore the first 7 rows
For i = .Cells(Rows.Count, "J").End(xlUp).Row To 7 Step -1
If .Cells(i, "J") < "08:00:00" Then
.Rows(i).Delete
End If
Next i
End With
End Sub
I think the problem im having is the date is in the same column as the time (01/03/2016 06:45:00). Im new to vba so any help would be appreciated.
Thanks!