Option Explicit
Sub F_Par_Client2()
With Application: .ScreenUpdating = False: .Calculation = xlManual: .EnableEvents = False: End With
Dim fFourn As Worksheet, fClients As Worksheet, tClients
Dim tabfin, i%, Annee As String
Dim start As Single
start = Timer
Set fFourn = Sheets("Fourn Par Client")
Set fClients = Sheets("Clients")
Set tabfin = fFourn.ListObjects("Tableau16")
tClients = fClients.Range("B3:P" & fClients.Range("B" & Rows.Count).End(xlUp).Row)
Annee = fFourn.Range("B2")
'Effacement du 1er tableau
Set tabfin = fFourn.ListObjects("Tableau16")
tabfin.DataBodyRange.Delete
Dim fMvtStock As Worksheet, fVentes As Worksheet, tMvtStock, tCommandes, a(), b()
Dim j%, n%, m%, k%
Set fMvtStock = Sheets("Mvts Stock")
tMvtStock = fMvtStock.Range("B3:V" & fMvtStock.Range("B" & Rows.Count).End(xlUp).Row)
'MsgBox "Durée du traitement: " & Timer - start & " secondes"
Dim dcli, dfourn
Set dcli = CreateObject("Scripting.Dictionary")
Set dfourn = CreateObject("Scripting.Dictionary")
dcli.CompareMode = vbTextCompare
dfourn.CompareMode = vbTextCompare
'Dico + tableau pour les clients en un seul coup
Dim Ok As Boolean, Ax&
For i = 1 To UBound(tMvtStock)
For j = 1 To UBound(tClients)
Ok = tMvtStock(i, 6) = tClients(j, 1) And tClients(j, 15) = "" And Year(tMvtStock(i, 1)) >= Annee
If Ok And Not dcli.exists(tMvtStock(i, 6)) Then
dcli(tMvtStock(i, 6)) = tMvtStock(i, 6)
Ax = Ax + 1: ReDim Preserve a(1 To 6, 1 To Ax): a(1, Ax) = tMvtStock(i, 6)
End If
Next j
Next i
a = Application.Transpose(a)
' et on continu (faire pareil pour dfourn et le tableau b )
'...
'...
MsgBox "dcli.count= " & dcli.Count & vbCrLf & "le ubound(a) = " & UBound(a)
With Application: .ScreenUpdating = True: .Calculation = xlAutomatic: .EnableEvents = True: End With
End Sub