I have been working on this for two days to no avail. I am extremely new to VBA.
In my macro I would like to delete the rows that have due dates more than 190 days away from today's date, and those with due dates that are within 70 days.
.Rows(i).delete is highlighted with the error "Compile error: Invalid or unqualified reference"
I can not figure this out for the life of me. If you know what I am doing wrong could you point out what and why it is wrong so that I can learn from this, please.
In my macro I would like to delete the rows that have due dates more than 190 days away from today's date, and those with due dates that are within 70 days.
Code:
Sub KeepBetween70and190()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("sheet2")
Application.ScreenUpdating = False
LastRow = Cells(Rows.Count, 8).End(xlUp).Row
For i = LastRow To 2 Step -1
If ws.Cells(i, 8).Value >= Date + 191 Or ws.Cells(H, 8).Value < Date + 70 Then
.Rows(i).Delete
End If
Next i
Application.ScreenUpdating = True
End Sub
.Rows(i).delete is highlighted with the error "Compile error: Invalid or unqualified reference"
I can not figure this out for the life of me. If you know what I am doing wrong could you point out what and why it is wrong so that I can learn from this, please.