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
|
For i = 1 To 5
nF = Choose(i, "BRUT_ROB", "BRUT_ROB2", "BRUT_ROB3", "BRUT_ROB4", "BRUT_ROB5")
'Filtre sur la date (1 semaine)
Sheets(nF).Range("$A$1:$E$10000").AutoFilter Field:=5, Operator:= _
xlFilterValues, Criteria2:=Array(2, "5/27/2015", 2, "5/28/2015", 2, "5/29/2015", 2, _
"5/30/2015", 2, "6/1/2015", 2, "6/2/2015", 2, "6/3/2015")
'Suppression des doublons
Sheets(nF).Cells.Select
Sheets(nF).Range("$A$1:$E$2563").RemoveDuplicates Columns:=Array(1, 2, 3, 4, 5) _
, Header:=xlNo
'Tri pour avoir des données ordonnées
ActiveWorkbook.Worksheets(nF).AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets(nF).AutoFilter.Sort.SortFields.Add Key:= _
Range("C1:C1933"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets(nF).AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveWorkbook.Worksheets(nF).AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets(nF).AutoFilter.Sort.SortFields.Add Key:= _
Range("A1:A1933"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets(nF).AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Application.DisplayAlerts = False 'Désactive les fenêtres d'alerte
'Création des sous totaux
Sheets(nF).Columns("C:C").Subtotal _
GroupBy:=1, Function:=xlCount, TotalList:=Array(1), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Sheets(nF).Columns("C:C").Delete Shift:=xlToLeft
Next i |
Partager