SUMIF COLOR

Solved
Amesam Posted messages 18 Registration date   Status Membre Last intervention   -  
Amesam Posted messages 18 Registration date   Status Membre Last intervention   -
Hello,

I’m stuck with a binder, a 2018 schedule.


I’m using this function:

Function SOMME_SI_COULEUR(PlageSomme As Range, PlageCouleur As Range) As Variant
'*********************************************************
' Sum the colored cells *
'*********************************************************
Dim Cel As Range
Dim Som As Double

If PlageCouleur.Cells.Count > 1 Then
SOMME_SI_COULEUR = CVErr(xlErrValue)
Exit Function
End If
For Each Cel In PlageSomme
If Cel.Interior.ColorIndex = PlageCouleur.Interior.ColorIndex Then Som = Som + Cel
Next
SOMME_SI_COULEUR = Som
End Function


For three years I’ve been using this function without issues, but now I can’t find why it’s not working.
I saved my file as .xlsm but same issue!

If anyone has any ideas, thanks for the feedback.

8 réponses

Amesam Posted messages 18 Registration date   Status Membre Last intervention   3
 
Hello mod100,

Yes, the colors are indeed identical. However, I realize that I should have 0 here and not #NAME?

=SUMIF_COLOR(B14:AF14; AH14)

AH14 being my blue reference (H+)

3
Pinzou76 Posted messages 750 Status Membre 192
 
Hello,
During a check, shouldn't we rather use "IF(a==b)" instead of "IF(a=b)"?
0
mdo100 Posted messages 126 Registration date   Status Membre Last intervention   22
 
Re Amesam,

Isn't your range B14:AF14 derived from conditional formatting? Because if that's the case, the function
=SOMME_SI_COULEUR(PlageSomme As Range, PlageCouleur As Range)
won't work.

I think you should attach your file to check all of this.

@+
0