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
| Sub recapp()
Application.ScreenUpdating = False
Dim F1 As Worksheet
Dim F2 As Worksheet
Set F1 = Sheets("Commandes")
Set F2 = Sheets("recapproduit")
F2.Cells.ClearContents
Dim DernLigne As Long
Dim DernColonne As Long
DernLigne = F1.Range("A" & Rows.Count).End(xlUp).Row
Dim i As Long
DernColonne = F1.Cells(1, Cells.Columns.Count).End(xlToLeft).Column
On Error Resume Next
Set d = CreateObject("Scripting.Dictionary")
TblBD = F1.Range(F1.Cells(2, 1), F1.Cells(DernLigne, DernColonne))
For i = 1 To UBound(TblBD)
clé = TblBD(i, 1)
For C = 2 To DernColonne
d(clé) = d(clé) + TblBD(i, C)
Next C
Next i
F2.Cells(1, 1) = "Code Produit"
F2.Cells(1, 2) = "Quantité"
F2.Range("A2").Resize(d.Count) = Application.Transpose(d.Keys)
F2.Range("B2").Resize(d.Count) = Application.Transpose(d.items)
Application.ScreenUpdating = True
End Sub |
Partager