Function RAverage(startdate As Date, enddate As Date, PG As String, DataRange As Range, CriteriaRange As Range)
Dim tablo1 As Variant
tablo1 = DataRange.Value
Criteria1 = CriteriaRange.Value
For n = LBound(tablo1, 1) + 1 To UBound(tablo1, 1)
If Criteria1(n, 1) = PG Then
For m = LBound(tablo1, 2) To UBound(tablo1, 2)
If tablo1(1, m) >= startdate And tablo1(1, m) <= enddate Then
tot = tot + tablo1(n, m)
End If
Next
End If
Next
nb = enddate - startdate + 1
RAverage = tot / nb
End Function