I am trying to delete whole rows of data if a date is more than a week later than today, but I don't want to delete the header. Today's date is a variable appearing in A2.
Edit: Column A has dates in the format of dd/mm/yyyy.
This code is what I have at the moment but it doesn't work and erases the header:
Sub deletedates()
Dim firstDate As Date, secondDate As Date
Dim i As Range
firstDate = DateValue(Range("A2"))
secondDate = DateAdd("d", 6, firstDate)
MsgBox secondDate
For Each i In Range("A:A")
If i.Value > secondDate Then
i.Select
ActiveCell.EntireRow.Delete
End If
Next i
End Sub