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
| Option Explicit
Sub W()
' Filtre élaborée et somme.si.ens sous 4 critères
' Je supprime les points du modèle de chiffrage anglo-saxon
Cells.Replace What:=".", Replacement:=".", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False
' J'établis par filtre avancé une sélection des 4 premières colonnes sans doublon et récupère selon ces critères les informations associées au 3 dernières colonnes
Range("A1:D1").Select
Selection.Copy
Range("N1").Select
ActiveSheet.Paste
Range("A2").Select
Application.CutCopyMode = False
Range("A:D").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
"N:Q"), Unique:=True
Range("E1:G1").Select
Selection.Copy
Range("R1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("A:G").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range( _
"N:Q"), CopyToRange:=Range("N1:T1"), Unique:=True
'J'applique la fonction somme.si.ens sur critères des 4 premières colonnes pour cumul des données (H:J)
Range("H1:J1").Select
Selection.Copy
Range("U1").Select
ActiveSheet.Paste
Range("U2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=+SUMIFS(C8,C1,RC[-7]&"""",C2,RC[-6]&"""",C3,RC[-5]&"""",C4,RC[-4]&"""")"
Range("U2").Select
Range("U2").AutoFill Destination:=Range("U2:U" & Range("S65536").End(xlUp).Row)
Range("U2").Select
Selection.Copy
Range("V2").Select
ActiveSheet.Paste
Range("V2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=+SUMIFS(C8,C1,RC[-8]&"""",C2,RC[-7]&"""",C3,RC[-6]&"""",C4,RC[-4]&"""")"
Range("V2").Select
ActiveCell.FormulaR1C1 = _
"=+SUMIFS(C9,C1,RC[-8]&"""",C2,RC[-7]&"""",C3,RC[-6]&"""",C4,RC[-5]&"""")"
Range("V2").Select
Range("V2").AutoFill Destination:=Range("V2:V" & Range("S65536").End(xlUp).Row)
Range("V2").Select
ActiveWindow.ScrollColumn = 11
Selection.AutoFill Destination:=Range("V2:W2"), Type:=xlFillDefault
Range("V2:W2").Select
Range("W2").Select
ActiveCell.FormulaR1C1 = _
"=+SUMIFS(C10,C1,RC[-9]&"""",C2,RC[-8]&"""",C3,RC[-7]&"""",C4,RC[-6]&"""")"
Range("W2").Select
Range("W2").AutoFill Destination:=Range("W2:W" & Range("S65536").End(xlUp).Row)
Range("W2").Select
' Je supprime les données initiales pour remplacement par les nouvelles
Range("U2:W2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("A:M").Select
Range("M1").Activate
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
End Sub |
Partager