Option Explicit
Sub test()
Dim d As Object, TbRes(), tbd(), dl As Long, ligne As Long, clé, lig As Integer
Dim BD As Worksheet, col As Byte
Set d = CreateObject("Scripting.Dictionary")
Set BD = Sheets("BD")
Application.ScreenUpdating = False
''//*********************************************************
tbd = BD.Range("A2:L" & BD.Cells(Rows.Count, 1).End(xlUp).Row).Value2
'totalisation par compte
ReDim TbRes(1 To UBound(tbd), 1 To 6)
For ligne = 1 To UBound(tbd)
clé = tbd(ligne, 3)
If Left(clé, 2) <> 88 Or Left(clé, 2) <> 99 Then '**condition qui pose problème
If d.exists(clé) Then
lig = d(clé)
Else
d(clé) = d.Count + 1
lig = d.Count ' index
TbRes(lig, 1) = tbd(ligne, 3)
TbRes(lig, 2) = tbd(ligne, 4)
TbRes(lig, 4) = tbd(ligne, 10)
TbRes(lig, 5) = tbd(ligne, 11)
End If
col = IIf(tbd(ligne, 5) = "Dépenses", 6, 7)
TbRes(lig, 3) = TbRes(lig, 3) + tbd(ligne, col)
End If
Next ligne
With Feuil2
.Cells.ClearContents
.[A1].Resize(UBound(TbRes), UBound(TbRes, 2)) = TbRes
End With
Application.ScreenUpdating = True
'
MsgBox "terminé"
Set BD = Nothing: Set d = Nothing: Erase tbd: Erase TbRes
End Sub