Hi,
Thank you for your answer.
I am however not able to make it work, am I supposed to type in both of the codes you have sent me?
This sheet is nr.2 and the date column in placed in column M. I do however also have a comment field in column N, thus the data expands column A - N and row 2 - 54 (however more equipment can be added/removed thus the total number of rows can change).
This is what I am typed into the VBA field:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lr As Integer
lr = Range("a" & Rows.Count).End(xlUp).Row
If Not Intersect(Range("m2:m" & lr), Target) Is Nothing Then
Range("am:m" & lr).Sort Key1:=Range("m1"), Order1:=xlAscending, Header:=xlYes
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lr As Integer, x As Integer
lr = Range("a" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
If Not Intersect(Range("m2:m" & lr), Target) Is Nothing Then
Range("a1:m" & lr).Sort Key1:=Range("m1"), Order1:=xlAscending, Header:=xlYes
Range("m" & lr).Interior.ColorIndex = -4142
For x = 2 To lr
With Range("m" & x)
Select Case Month(Range("m" & x).Value)
Case Is < Month(Date)
.Interior.ColorIndex = 3
Case Is = Month(Date)
.Interior.ColorIndex = 46
Case Is > Month(Date)
.Interior.ColorIndex = 4
End Select
Select Case Year(Range("m" & x))
Case Is > Year(Date)
.Interior.ColorIndex = 4
Case Is < Year(Date)
.Interior.ColorIndex = 3
End Select
If IsEmpty(Range("m" & x)) Then
.Interior.ColorIndex = -4142
End If
End With
Next x
End If
It automatically came a line between the two codes, is that correct?
Kind regards,
Renate Bringsli