hi, actually my code doesn't work at all i need help to fix it
The date in the cell. I want the cell to keep its color green if the cell’s date is 6 months and yellow months less than today's date and red if it is one month after the date of the day and it remains in the cell next to it. If the Done planted color the color disappears and the cell returns white without coloring
Code
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim lr As Integer, i As Integer
lr = Cells(Rows.Count, "e").End(xlUp).Row
For i = 2 To lr
If Cells(i, 5) < Month(Date) - 6 Then Cells(i, 5).Interior.Color = vbGreen
If Cells(i, 5) = Date Then Cells(i, 5).Interior.Color = vbYellow
If Month(CDate(Cells(i, 5))) > Month(Date) + 1 Then Cells(i, 5).Interior.Color = vbRed
If Cells(i, 4) = "DONE" Then Cells(i, 4).Interior.Color = vbWhite
Next i
End Sub