Function MoySpc(r As Range)
Dim Cel As Range, i&, s#
For Each Cel In r.Cells
If Cel.NumberFormat = "0%" Then i = i + 1: s = s + Cel.Value
Next
If i Then MoySpc = s / i Else MoySpc = ""
End Function
=SOMME.SI(D8:L8;"<1")/NB.SI(D8:L8;"<1")
Cette formule tiens compte des valeurs 0... comment arriver à ne compter que les valeurs en % sans utiliser de code?
Correction de la fonction personnalisée proposée plus haut :
VB:
Function MoySpc(r As Range)
Application.Volatile
Dim Cel As Range, i&, s#
For Each Cel In r.Cells
If Cel.NumberFormat = "0%" And Not IsEmpty(Cel) Then i = i + 1: s = s + Cel.Value
Next
If i Then MoySpc = s / i Else MoySpc = ""
End Function