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
| Sub comptabiliser()
Dim F1 As Worksheet, F2 As Worksheet
Dim Tablo, i As Long
Set F1 = Sheets("Factures")
Set F2 = Sheets("Compta")
Tablo = F1.Range("A2", "Z" & F1.Range("A" & Rows.Count).End(xlUp).Row).Value2
Set dict = CreateObject("scripting.dictionary")
dict.Add dict.Count, Array("Date", "code journal", "compte", "débit", "crédit", " ") 'les titles
For i = 1 To UBound(Tablo) 'IMPORTANT, CHAQUE LIGNE DOIT AJOUTER LE MÊME NOMBRE D'ELEMENTS DANS "ITEMS" = 8 !!!
dict.Add dict.Count, Array(Tablo(i, 2), ("VT"), "70600000", "", Tablo(i, 10), Tablo(i, 6), Tablo(i, 1), Tablo(i, 9))
Next i
arr = Application.Index(dict.items, 0, 0)
F2.Cells.ClearContents
With F2.Range("A1").Resize(UBound(arr), UBound(arr, 2))
.Value = arr
.EntireColumn.AutoFit
.Sort .Range("G1"), xlAscending, Header:=xlYes
End With
Sheets("Compta").Select
Columns("A:A").Select
Selection.NumberFormat = "m/d/yyyy"
End Sub |
Partager