1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Sub test()
Dim f1 As Worksheet
Dim f2 As Worksheet
Dim TblBD
Dim L As Long
Set f1 = Sheets("MVTS")
Set f2 = Sheets("ETAT_STOCK")
L = f1.Range("A" & Rows.Count).End(xlUp).Row
f2.Range("A6:I" & L).ClearContents
Set d = CreateObject("scripting.dictionary")
d.CompareMode = vbTextCompare
derlig = f1.Range("A" & Rows.Count).End(xlUp).Row
TblBD = f1.Range("A2:J" & derlig)
For i = 1 To UBound(TblBD)
clé = TblBD(i, 3) & "|" & TblBD(i, 4) & "|" & TblBD(i, 5)
d(clé) = d(clé) + TblBD(i, 6)
Next i
f2.Range("A6").Resize(d.Count) = Application.Transpose(d.keys)
f2.Range("D6").Resize(d.Count) = Application.Transpose(d.items)
Application.DisplayAlerts = False
f2.Range("A6").Resize(d.Count).TextToColumns Other:=1, OtherChar:="|"
f2.Range("D6").Resize(d.Count).TextToColumns Other:=1, OtherChar:="|"
End Sub |
Partager