Function CompteCoul(ref As Range, r As Range)
Application.Volatile
Dim coul&
coul = ref.Interior.ColorIndex
For Each r In r
If r.Interior.ColorIndex = coul Then CompteCoul = CompteCoul + 1
Next
End Function
Sub Couleur() 'macro affectée aux boutons
If IsError(Application.Caller) Then Exit Sub 'sécurité
Dim P As Range, jour As Range, base As Range, i As Variant, coul&, c As Range
Set P = [D10:AH63] 'à adapter
Set jour = [8:8] 'ligne à adapter
Set base = [E65:E68] 'à adapter
i = Application.Match(ActiveSheet.DrawingObjects(Application.Caller).Text, base, 0)
If IsError(i) Then coul = xlNone Else coul = base(i, 0).Interior.ColorIndex
ActiveCell.Activate 'si un objet est sélectionné
On Error Resume Next
For Each c In Selection
If Intersect(c, P) Is Nothing Or Weekday(jour(c.Column)) = 1 Then Else c.Interior.ColorIndex = coul
Next
Calculate 'recalcule les formules volatiles
End Sub