XL 2016 sommme couleur fond affiche #VALEUR!

Claudy

XLDnaute Accro
Bonjour à tous,

dans un gros tableau Organique, j'utilise la fonction SommeCouleurFond....(Voir ci dessous)

La formule affiche bien la bonne somme...mais quelques instant après, #VALEUR! s'affiche.

Avez vous une explication?
merci d'avance,
Claudy








Function SommeCouleurFond(PlageSomme As Range, PlageCouleur As Range) As Variant
'*********************************************************
' Effectuer la somme des cellules en couleur *
'*********************************************************
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
 

jpb388

XLDnaute Accro
Bonjour à tous
essaye
VB:
Function SommeCouleurFond(PlageSomme As Range, PlageCouleur As Range) As Variant
'*********************************************************
' Effectuer la somme des cellules en couleur *
'*********************************************************
Dim Cel As Range
Dim Som As Double

If PlageCouleur.Cells.Count > 1 Then
MsgBox "La plage couleur ne doit contenir qu'une cellule", vbOKOnly, "Erreur de saisie"
Exit Function
End If
For Each Cel In PlageSomme
If Cel.Interior.ColorIndex = PlageCouleur.Interior.ColorIndex Then Som = Som + Cel
Next
SommeCouleurFond = Som
End Function
 

Discussions similaires

Statistiques des forums

Discussions
311 720
Messages
2 081 912
Membres
101 837
dernier inscrit
Ugo