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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
| Sub Macro2()
' Macro2 Macro
'Copiage de la BASE sur nouvel onglet
Sheets("BASE").Select
Sheets("BASE").Copy After:=Sheets(3)
'Tri ordre croissant colonne A + Onglet renommé
ActiveWorkbook.Worksheets("BASE (2)").AutoFilter.Sort.SortFields.Clear
Worksheets("BASE (2)").Name = "MO1"
'Comment indiquer de trier par la colonne A et pas seulement de A1 à A191 ?
ActiveWorkbook.Worksheets("MO1").AutoFilter.Sort.SortFields.Add Key:= _
Range("A1:A191"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortTextAsNumbers
With ActiveWorkbook.Worksheets("MO1").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'Insertion des 2 colonnes
Columns("M:M").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("M:M").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
'Somme en ligne des colonnes M et R
'Comment ne pas se limiter à M191 ?
Range("M2:M191").FormulaLocal = "=SOMME(D2:L2)"
Range("M2").Copy Range("M3:M191")
Range("R2").FormulaLocal = "=SOMME(O2:R2)"
Range("R2").Copy Range("R3:R191")
'Renommer les colonnes
Range("A1") = "Service"
Range("B1") = "Matricule"
Range("C1") = "Nom Prénom"
Range("D1") = "Compteur 22 RCHS"
Range("E1") = "Compteur 23 RCDI"
Range("F1") = "Compteur 24 RCTP"
Range("G1") = "Compteur 25 RCJF"
Range("H1") = "Compteur 63 HARE"
Range("I1") = "Compteur 68 Reliquat"
Range("J1") = "Compteur 69 PRHH"
Range("K1") = "Compteur 32 H Récup"
Range("L1") = " Compteur 47 CC"
Range("M1") = "Total HEURES"
Range("N1") = "Compteur 47 Jours"
Range("O1") = "Compteur 44 CP-1"
Range("P1") = "Compteur 46 CP"
Range("Q1") = "Compteur 50 CET"
Range("R1") = "Total JOURS"
'Déplacer les valeurs selon l'onglet SALJOUR
'Sous total par service
'Comment sélectionner la plage active et pas seulement A1:R20 ?
Range("A1:R20").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(4, 5, 6, 7, _
8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18), Replace:=True, PageBreaks:=False, _
SummaryBelowData:=True
ActiveWindow.SmallScroll Down:=-180
'Mettre en forme
'Centrer et retour à la ligne des colonnes
Rows("1:1").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End Sub |
Partager