Copy and paste this macro into the "2014" worksheet code module. Do the following: right click the tab for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Change either the start date or end date and exit the cell.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim bottomC As Integer
bottomC = Sheets("2014").Range("C" & Rows.Count).End(xlUp).Row
If Intersect(Target, Range("C6:D" & bottomC)) Is Nothing Then Exit Sub
Application.ScreenUpdating = False
Dim rng1 As Range
Dim rng2 As Range
Dim lCol As Long
lCol = Cells(5, Columns.Count).End(xlToLeft).Column
Dim bottomA As Long
bottomA = Sheets("Color Codes").Range("A" & Rows.Count).End(xlUp).Row
Dim section As Range
If Target.Column = 3 Then
For Each section In Sheets("Color Codes").Range("A1:A" & bottomA)
If Target.Offset(0, -2) = section Then
ActiveSheet.Rows(Target.Row).Interior.ColorIndex = xlNone
For Each rng1 In Range(Cells(5, 5), Cells(5, lCol))
If rng1 = Target Then
For Each rng2 In Range(Cells(5, "E"), Cells(5, lCol))
If rng2 = Target.Offset(0, 1) Then
Range(Cells(Target.Row, rng1.Column), Cells(Target.Row, rng2.Column)).Interior.ColorIndex = section.Offset(0, 1).Interior.ColorIndex
End If
Next rng2
End If
Next rng1
End If
Next section
End If
If Target.Column = 4 Then
For Each section In Sheets("Color Codes").Range("A1:A" & bottomA)
If Target.Offset(0, -3) = section Then
ActiveSheet.Rows(Target.Row).Interior.ColorIndex = xlNone
For Each rng1 In Range(Cells(5, 5), Cells(5, lCol))
If rng1 = Target Then
For Each rng2 In Range(Cells(5, "E"), Cells(5, lCol))
If rng2 = Target.Offset(0, -1) Then
Range(Cells(Target.Row, rng1.Column), Cells(Target.Row, rng2.Column)).Interior.ColorIndex = section.Offset(0, 1).Interior.ColorIndex
End If
Next rng2
End If
Next rng1
End If
Next section
End If
Application.ScreenUpdating = True
End Sub
Bookmarks