Function MoyenneN(xrg As Range, xn&)
Dim v, j&, n&, m&, s&
v = xrg.Value
For j = 1 To UBound(v, 2)
If v(1, j) <> "" Then n = n + 1: v(1, n) = v(1, j)
Next j
If n < xn Then MoyenneN = CVErr(xlErrNA): Exit Function
For j = 1 To xn
If v(1, j) <> 0 Then m = m + 1: s = s + v(1, j)
Next j
If m = 0 Then MoyenneN = CVErr(xlErrDiv0): Exit Function
MoyenneN = s / m
End Function