Formule VBA incomplète
Bonjour le forum
je vous écris car j'ai besoin de votre aide car ma formule VBA est incomplète .
je dois gérer des écritures comptables en filtrant les données et les afficher dans une autre feuille ce que j'ai réussi mais je viens de m'apercevoir que Je n'ai pas la formule qui change le compte client en fonction du libéllé rendu
si quelqu'un pourrait m'aider ca serai extrêmement cool
cordialement
PS : voici un fichier d'exemple pour pouvoir comprendre Le rendu (feuill2) et la formule E4,E7, et E10 celle commencant par 411
sub comptabiliser()
Dim F1 As Worksheet
Dim F2 As Worksheet
Set F1 = Sheets("Factures")
Set F2 = Sheets("Compta")
Dim Tablo
F2.Cells.ClearContents
Dim i As Long
Application.ScreenUpdating = False
Tablo = F1.Range("A2", "Z" & F1.Range("A" & Rows.Count).End(xlUp).Row)
F2.Cells(1, 1).Resize(1, 8) = Array("Date", "code journal", "compte", "débit", "crédit", "Libellé pièce", "Pièce", "référence pièce")
Set d = CreateObject("Scripting.Dictionary")
Set d1 = CreateObject("Scripting.Dictionary")
Set d2 = CreateObject("Scripting.Dictionary")
For i = 1 To UBound(Tablo)
clé = Tablo(i, 2) & "|" & Tablo(i, 9) & "|" & "70600000" & "|" & "" & "|" & Tablo(i, 10) & "" & "|" & Tablo(i, 6) & "|" & Tablo(i, 1) & "|" & Tablo(i, 9)
clé1 = Tablo(i, 2) & "|" & Tablo(i, 9) & "|" & "44571200" & "|" & "" & "|" & Tablo(i, 11) & "" & "|" & Tablo(i, 6) & "|" & Tablo(i, 1) & "|" & Tablo(i, 9)
clé2 = Tablo(i, 2) & "|" & Tablo(i, 9) & "|" & "411" & Tablo(1, 5) & "|" & Tablo(i, 12) & "" & "|" & "" & "|" & Tablo(i, 6) & "|" & Tablo(i, 1) & "|" & Tablo(i, 9)
d(clé) = d(clé)
d1(clé1) = d1(clé1)
d2(clé2) = d2(clé2)
Next i
F2.Range("A2").Resize(d.Count) = Application.Transpose(d.keys)
F2.Range("A2").Resize(d.Count).TextToColumns Other:=1, DataType:=xlDelimited, OtherChar:="|"
j = F2.Cells(Rows.Count, 1).End(xlUp).Row + 1
F2.Range("A" & j).Resize(d.Count) = Application.Transpose(d1.keys)
F2.Range("A" & j).Resize(d.Count).TextToColumns Other:=1, DataType:=xlDelimited, OtherChar:="|"
L = F2.Cells(Rows.Count, 1).End(xlUp).Row + 1
F2.Range("A" & L).Resize(d.Count) = Application.Transpose(d2.keys)
F2.Range("A" & L).Resize(d.Count).TextToColumns Other:=1, DataType:=xlDelimited, OtherChar:="|"
F2.Select
Call flitrer
Application.ScreenUpdating = True
End Sub
Sub flitrer()
Dim DerLig As Long
Application.ScreenUpdating = False
With Sheets("Compta")
.Select
.AutoFilterMode = False
DerLig = .Range("A" & Rows.Count).End(xlUp).Row
.Range("A1:H" & DerLig).Select
.Sort.SortFields.Clear
.Sort.SortFields.Add Key:=Range("G1:G" & DerLig) _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With .Sort
.SetRange Range("A1:H" & DerLig)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End With
End Sub