Hi again,
I made it work for sheet 2 in my excel file (where the date column is placed in column M). However, for sheet 1 (where the date column is placed in column L), I am not able to make it work although I have been trying to modify the coding to fit this column instead.
The code I am using for sheet 1 is as following:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lr As Integer
lr = Range("a" & Rows.Count).End(xlUp).Row
If Not Intersect(Range("l2:l" & lr), Target) Is Nothing Then
Range("a1:m" & lr).Sort Key1:=Range("l1"), Order1:=xlAscending, Header:=xlYes
End If
Dim lr2 As Integer, x As Integer
lr2 = Range("a" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
If Not Intersect(Range("l2:l" & lr2), Target) Is Nothing Then
Range("a1:l" & lr2).Sort Key1:=Range("l1"), Order1:=xlAscending, Header:=xlYes
Range("l" & lr2).Interior.ColorIndex = -4142
For x = 2 To lr2
With Range("l" & x)
Select Case Month(Range("l" & x).Value)
Case Is < Month(Date)
.Interior.ColorIndex = 3
Case Is = Month(Date)
.Interior.ColorIndex = 46
Case Is > Month(Date)
.Interior.ColorIndex = 10
End Select
Select Case Year(Range("l" & x))
Case Is > Year(Date)
.Interior.ColorIndex = 10
Case Is < Year(Date)
.Interior.ColorIndex = 3
End Select
If IsEmpty(Range("l" & x)) Then
.Interior.ColorIndex = -4142
End If
End With
Next x
End If
Application.ScreenUpdating = True
End Sub
Do you have any idea what the problem is ? when I run it it stops in row 13 of the coding, this get marked in yellow.
Kind regards,
Renate