Private Sub Worksheet_Activate()
Worksheet_Change [AE1] 'lance la macro
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, [AE1]) Is Nothing Then Exit Sub
Dim ferie As Range, vacance, ub%, r As Range, i%
Set ferie = [_tb_Fériés[Date]]
vacance = [_tb_ZB].Resize(, 3) 'matrice, plus rapide
ub = UBound(vacance)
Set r = [A5:AC35,A50:AC80] 'plages adaptables
Application.ScreenUpdating = False
r.Interior.ColorIndex = xlNone 'RAZ
For Each r In r
If IsDate(r) Then
With r(1, 0).Resize(, 4).Interior
If Weekday(r, 2) > 5 Then .Color = RGB(217, 225, 242) 'bleu clair
For i = 1 To ub
If r >= vacance(i, 2) And r <= vacance(i, 3) Then .Color = RGB(153, 255, 153): Exit For 'vert clair
Next i
If IsNumeric(Application.Match(CLng(r), ferie, 0)) Then .Color = RGB(248, 203, 173) 'rose
End With
End If
Next r
End Sub
Private Sub CommandButton1_Click() 'bouton RAZ
If MsgBox("Etes-vous sûr de vouloir effacer les libellés ?", vbQuestion + vbYesNo, "Effacer") = 7 Then Exit Sub
On Error Resume Next 'si aucune SpecialCell
With [A5:AC35,A50:AC80] 'plages adaptables
.SpecialCells(xlCellTypeConstants) = ""
.SpecialCells(xlCellTypeBlanks).Font.Color = RGB(48, 84, 150)
End With
End Sub