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
| Sub Regroupement()
VidangerFeuilleRecapitulative
CreerListeProjetsRecap
CreerFormulesRecap
End Sub
Sub VidangerFeuilleRecapitulative()
shRecap.Range(shRecap.Cells(2, 1), shRecap.Cells(Rows.Count, Columns.Count)).ClearContents
End Sub
Sub CreerListeProjetsRecap()
Dim oDico As Scripting.Dictionary
Dim i As Integer
Set oDico = ListeProjets()
For i = 0 To oDico.Count - 1
shRecap.Range("a" & Rows.Count).End(xlUp)(2).Value = oDico.Items(i)
Next i
End Sub
Function ListeProjets() As Scripting.Dictionary
Dim Cellule As Range
Dim oDico As New Scripting.Dictionary
For Each Cellule In shDonnees.Range("a2:a" & shDonnees.Range("a" & Rows.Count).End(xlUp).Row)
If Not oDico.Exists(Cellule.Value) Then oDico.Add Cellule.Value, Cellule.Value
Next Cellule
Set ListeProjets = oDico
Set oDico = Nothing
End Function
Sub CreerFormulesRecap()
shRecap.Range("b2").Formula = "=SUMIF(OFFSET(ReqProjets,0,0,,1),A2,OFFSET(ReqProjets,0,1,,1))"
shRecap.Range("c2").Formula = "=SUMIF(OFFSET(ReqProjets,0,0,,1),A2,OFFSET(ReqProjets,0,2,,1))"
shRecap.Range("b2:c2").Copy Destination:=shRecap.Range("b2:b" & shRecap.Range("a" & Rows.Count).End(xlUp).Row)
shRecap.Range("b2:c" & shRecap.Range("a" & Rows.Count).End(xlUp).Row).Copy
shRecap.Range("b2:c" & shRecap.Range("a" & Rows.Count).End(xlUp).Row).PasteSpecial xlPasteValues
Application.CutCopyMode = False
End Sub |
Partager