Function moyarit(X As Range, N As Range) As Double
Dim c As Integer
Dim l As Integer
Dim i As Integer
Dim j As Integer
Dim moy As Double
Dim k As Integer
Dim coeff As Integer
c = X.Columns.Count
l = X.Rows.Count
moy = 0
coeff = 0
Select Case True
Case (X.Rows.Count = N.Rows.Count And X.Columns.Count = N.Columns.Count)
For i = 1 To l
For j = 1 To c
moy = (moy + X.Cells(i, j) * N.Cells(i, j))
Next i
Next j
End Select
For i = 1 To l
For j = 1 To c
coeff = coeff + N.Cells(i, j)
Next i
Next j
moyarit = moy / coeff
End Function