Option Base 1
Public Plage_Rentas As Range
Sub MM()
Dim page As Worksheet
For Each page In ThisWorkbook.Worksheets
If page.Name <> "Statistiques" Then
page.Activate
Call MoyenneM
End If
Next page
End Sub
Sub MoyenneM()
Dim l As Integer, y As Integer
l = 20
y = 50
Dim premier As Integer, dernier As Integer, i As Integer, v As Integer
premier = 3
dernier = Range("B2").End(xlDown).Row
For i = premier To dernier - 20
Dim M20Range As Range
Set M20Range = Range(Cells(i, 2), Cells(i + l - 1, 2))
Cells(i + l - 1, 9) = Application.WorksheetFunction.Average(M20Range)
Next i
For v = premier To dernier - 50
Dim M50Range As Range
Set M50Range = Range(Cells(v, 2), Cells(v + y - 1, 2))
Cells(v + y - 1, 10) = Application.WorksheetFunction.Average(M50Range)
Next v
End Sub