Gestion série dans fonction

Bonjour,

je souhaite faire une fonction qui somme le nombre de cellules colorées (couleur déclarée par PlageCouleur) d'une colonne ( PlageSomme) et qui répondent à 2 critères : la cellule contient un caractère déclaré + la cellule se situant sur la même ligne de la colonne (Plagecritere) contient le critere (critere)

Pourriez-vous m'aider à debugger ma fonction qui ne marche pas ....

merci

Function SOMMECOULEURNONVIDECRITERE(PlageSomme As Range, PlageCouleur As Variant, Plagecritere As Range, critere As Variant) As Variant

Application.Volatile

Dim Cel As Range

Dim Som As Variant

Som = 0

For Each Cel In PlageSomme

If Cel.Interior.ColorIndex = PlageCouleur.Interior.ColorIndex Then

If IsEmpty(Cel) = False Then

If Cells(Cel.Raw, Range("Plagecritere").Column).Value = critere Then

Som = Som + 1

End If

End If

End If

Next

SOMMECOULEURNONVIDECRITERE = Som

End Function

Bonjour,

proposition de correction, ne fonctionne pas avec les couleurs issues d'une mise en forme conditionnelle.

Function SOMMECOULEURNONVIDECRITERE(PlageSomme As Range, PlageCouleur As Variant, Plagecritere As Range, critere As Variant) As Variant
    Application.Volatile
    Dim Cel As Range
    Dim Som As Variant
    Som = 0
    For Each Cel In PlageSomme
        If Cel.Interior.ColorIndex = PlageCouleur.Interior.ColorIndex Then
            If Cel <> "" Then
                If Plagecritere.Cells(Cel.Row, 1).Value = critere Then
                    Som = Som + 1
                End If
            End If
        End If
    Next
    SOMMECOULEURNONVIDECRITERE = Som
End Function

cela fonctionne. Un grand merci !

Rechercher des sujets similaires à "gestion serie fonction"