Sub Som_cel_coul()
Dim i As Integer, Tot As Long
Tot = 0
For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row
If Cells(i, 1).Interior.ColorIndex = 6 Then
Tot = Tot + Cells(i, 1)
End If
Next
MsgBox "le total des cellules de couleur jaune est de : " & Tot
End Sub
Function SommeCouleurFond(champ As Range, couleurFond)
Application.Volatile
Dim c, temp
temp = 0
For Each c In champ
If c.Interior.ColorIndex = couleurFond Then
If IsNumeric(c.Value) Then temp = temp + c.Value
End If
Next c
SommeCouleurFond = temp
End Function
Dim celluleAvant
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not IsEmpty(celluleAvant) Then
If Not Intersect(Range(celluleAvant), [B2:G3]) Is Nothing Then Calculate
End If
celluleAvant = Target.Address
End Sub