JeremyA1976
Board Regular
- Joined
- Aug 3, 2015
- Messages
- 59
Hi all,
I have a VBA code I am using that will change a specific cell in column L to a fill of yellow or icolor=6 if it matches todays date. If the date in column L is before todays date, I want it to turn red or icolor=3. (I would prefer if it would stay yellow for 3 days instead of 1 day, but I can live with that). So our receiving manager gets a warning when something is overdue. If the date in the column is beyond todays date, I want it to be white fill or icolor=2, so he knows it is still out for delivery. The problem is... When I insert a date and then delete it, the cell turns red and I am not sure why. Anyone have any clue why this is happening? Code is below.
I have a VBA code I am using that will change a specific cell in column L to a fill of yellow or icolor=6 if it matches todays date. If the date in column L is before todays date, I want it to turn red or icolor=3. (I would prefer if it would stay yellow for 3 days instead of 1 day, but I can live with that). So our receiving manager gets a warning when something is overdue. If the date in the column is beyond todays date, I want it to be white fill or icolor=2, so he knows it is still out for delivery. The problem is... When I insert a date and then delete it, the cell turns red and I am not sure why. Anyone have any clue why this is happening? Code is below.
Code:
Private Sub Worksheet_Change(ByVal Target As Range) Dim icolor As Integer
Dim cell As Range
If Intersect(Target, Range("L3:L10000")) Is Nothing Then Exit Sub
For Each cell In Target
icolor = 0
Select Case cell
Case Is = Date: icolor = 6
Case Is > Date: icolor = 2
Case Is < Date + 1: icolor = 3
Case "": icolor = 2
End Select
If icolor <> 0 Then cell.Interior.ColorIndex = icolor
Next cell
End Sub