1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Sub Macro2()
Dim Wb As Workbook
Dim i As Integer, Nb As Integer
Dim x As Range
'.....initialisation de Wb et Nb
'....
With Wb.Worksheets("entreprise")
For i = 3 To 5
Set x = Wb.Worksheets(3).Cells(i, 2).Resize(1, Nb)
.Cells(1, i).Value = WorksheetFunction.Average(x)
Set x = Wb.Worksheets(4).Cells(i, 2).Resize(1, Nb)
.Cells(7, i).Value = WorksheetFunction.Average(x)
Set x = Wb.Worksheets(5).Cells(i, 2).Resize(1, Nb)
.Cells(14, i).Value = WorksheetFunction.Average(x)
Set x = Nothing
Next i
End With
End Sub |