Bonjour
Avec ta macro modifiée
Sub NombredeCellulesvertes()
'Ligne 9
Dim Cellule As Range
Dim total As Variant
For Each Cellule In Range("Scores")
If Cellule.Interior.ColorIndex = 14 Then 'Vert
total = total + Cellule
End If
Next
Range("Q2") = total
End Sub
Avec une fonction personnalisée
Tu peux faire la somme de la couleur que tu veux, il suffit de lui transmettre en paramètre une cellule ayant la bonne couleur
Function SommeCouleurs(Plage As Range, Ref As Range)
'Ligne 9
Dim Cellule As Range
Dim total As Variant
Application.Volatile
For Each Cellule In Plage
If Cellule.Interior.ColorIndex = Ref.Interior.ColorIndex Then
total = total + Cellule
End If
Next
SommeCouleurs = total
End Function
Utilisation : Dans une cellule
=SommeCouleurs(Scores;N3)