Can do this with an event driven macro

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Possible As Boolean
Dim Cell As Range
Dim StartDate As Date
Dim EndDate As Date
Dim StartMonth As Integer
Dim EndMonth As Integer
Dim StartWeek As Integer
Dim EndWeek As Integer
Dim StartDay As Integer
Dim EndDay As Integer


Application.EnableEvents = False
Possible = False
For Each Cell In Target
    If Cell.Column = 6 And Cell.Row >= 3 Then
        If Cell.Offset(0, 1) > Cell Then
            Possible = True
        End If
    End If
    If Cell.Column = 7 And Cell.Row >= 3 Then
        If Cell.Offset(0, -1) < Cell Then
            Possible = True
        End If
    End If
    
    If Possible = True Then
        Range(Cells(Cell.Row, 9), Cells(Cell.Row, 24)).Interior.ColorIndex = -4142
        StartDate = Cells(Cell.Row, 6)
        EndDate = Cells(Cell.Row, 7)
        
        StartMonth = Month(StartDate)
        EndMonth = Month(EndDate)
        
        StartWeek = Int(((Day(StartDate) - 1) / 7)) + 1
        EndWeek = Int(((Day(EndDate) - 1) / 7)) + 1
        
        For M = (StartMonth * 4) - 28 + StartWeek To (EndMonth * 4) - 28 + EndWeek
            
            If M = (EndMonth * 4) - 28 + EndWeek Then
                Cells(Cell.Row, M).Interior.ColorIndex = 4
            ElseIf M > 20 Then
                Cells(Cell.Row, M).Interior.ColorIndex = 3
            Else
                Cells(Cell.Row, M).Interior.ColorIndex = 6
            End If
        
        Next M
    End If

Next Cell
Application.EnableEvents = True
End Sub
Paste the above code into the Sheet4(Main Sheet) tab in the VBA editor (Alt F11). Remember to save the workbook as macro enabled .xlsm