1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| Option Explicit
Function Statistiques(Sht As Worksheet, X, i As Integer)
Dim LastLig As Long
Dim PlageRentas As Range
With Sht
LastLig = .Cells(Rows.Count, "C").End(xlUp).Row
Set PlageRentas = .Range("D2:D" & LastLig)
X(i, 0) = Sht.Name
X(i, 1) = PlageRentas.Cells.Count
With Application.WorksheetFunction
X(i, 2) = .Average(PlageRentas)
X(i, 3) = .Median(PlageRentas)
X(i, 4) = .StDev(PlageRentas)
X(i, 5) = .Skew(PlageRentas)
X(i, 6) = .Kurt(PlageRentas)
End With
End With
Statistiques = X
End Function
Sub Calculate_Rentas(ws As Worksheet)
Dim LastLig As Long
With ws
LastLig = .Cells(Rows.Count, "C").End(xlUp).Row
.Range("D2:D" & LastLig - 1).FormulaR1C1 = "=ln((R[1]C2 + RC3) / RC2)"
End With
End Sub
Sub statistiques_elémentaires()
Dim TabResult() As Variant
Dim Ligne_Tableau As Integer, Nb_Actions As Integer
Dim Feuille As Worksheet
Nb_Actions = ThisWorkbook.Worksheets.Count - 1
ReDim TabResult(0 To Nb_Actions, 7)
Ligne_Tableau = 0
For Each Feuille In ThisWorkbook.Worksheets
If Feuille.Name <> "Statistiques" Then
Call Calculate_Rentas(Feuille)
TabResult = Statistiques(Feuille, TabResult, Ligne_Tableau)
Ligne_Tableau = Ligne_Tableau + 1
End If
With Worksheets("Statistiques")
.Range(.Cells(2, 1), .Cells(Nb_Actions + 1, 7)).Value = TabResult
End With
Next Feuille
End Sub |
Partager