Function NbJC(Plage As Range, N%)
Dim critere$, pc%, i%, test As Byte, deb%, j%
critere = "#CP#REP#RTT#" 'à adapter
pc = Plage.Count
a = 0
For i = 1 To pc
test = InStr(critere, "#" & UCase(Plage(i)) & "#")
'--1 : Compte si N jours consécutifs pour les critères
If test = 0 Then
If a >= N Then NbJC = IIf(NbJC = 0, a, NbJC + a)
a = 0
End If
If test > 0 Then a = a + 1
Next
If IsEmpty(NbJC) Then NbJC = "" 'masque les valeurs zéro
End Function