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
|
Static Function MEF_1er_slide(nom_table As Worksheet)
ThisWorkbook.Sheets("nom_table").Activate
'Mettre en forme les en-têtes du tableau
Range(Cells(1, 1), Cells(1, 4)).Select
Selection.Font.Bold = True ' mettre en gras
Selection.Font.ColorIndex = 2 ' mettre en blanc
Selection.Interior.ColorIndex = 30 ' mettre la cellule en bordeau
Cells(1, 1).Value = "Notations"
Cells(1, 2).Value = "Circuit"
Cells(1, 3).Value = "En nombre"
Cells(1, 4).Value = "En %"
'Centrer les données du tableau
Cells(1, 1).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
With Selection
.HorizontalAlignment = xlHAlignCenter
.VerticalAlignment = xlVAlignCenter
End With
'On tri la colonne A de façon décroissante en déclarant A1 comme en-tête
Range("A1").Sort , Key1:=Columns("A"), Header:=xlGuess, Order1:=xlDescending
i = 0
Cells(1, 1).Select
'On compte le nombre de OK
For Each cellule In Range(Selection, Selection.End(xlDown))
If cellule.Value = "OK" Then i = i + 1
Next
'Réalise la somme pour les "Total"
Rows(i + 2).Insert
Cells(i + 2, 1).Value = "Total"
Cells(i + 2, 3).Value = Application.WorksheetFunction.Sum(Range(Cells(2, 3), Cells(i + 2, 3)))
Cells(i + 2, 4).Value = Application.WorksheetFunction.Sum(Range(Cells(2, 4), Cells(i + 2, 4)))
'Calcul somme pour "notations (*)"
Cells(k + 2, 1).Value = "Notations (*)"
Cells(k + 2, 3).Value = Cells(i + 2, 3).Value + Cells(k + 1, 3).Value
Cells(k + 2, 4).Value = Cells(i + 2, 4).Value + Cells(k + 1, 4).Value
etc... plein d'autres retraitements
End Function |