Sub ComptePostes()
Dim Dico, Dico2, i As Long, TabIni, TabFin, x As Integer, LD As Integer
Set Dico = CreateObject("Scripting.Dictionary")
Set Dico2 = CreateObject("Scripting.Dictionary")
x = 0
Application.ScreenUpdating = False
With Worksheets("Feuil1")
TabIni = .Range("A2:B" & .Range("B" & Rows.Count).End(xlUp).Row)
For i = LBound(TabIni) To UBound(TabIni)
Dico(TabIni(i, 1)) = "" '
Next
ReDim TabFin(1 To Dico.Count, 1 To 3)
For Each clé In Dico.keys
For i = LBound(TabIni) To UBound(TabIni)
If TabIni(i, 1) = clé Then Dico2(TabIni(i, 2)) = ""
Next
x = x + 1
TabFin(x, 1) = clé
TabFin(x, 2) = Dico2.Count
TabFin(x, 3) = "=VLOOKUP(Résultat!RC[-2],Feuil1!RC[-2]:R[8]C[-1],2,FALSE)"
Dico2.RemoveAll
Next
End With
With Sheets("Résultat")
LD = 2
.Select
.Range("A2:B1000").ClearContents
.Range("A" & LD).Resize(UBound(TabFin, 1), UBound(TabFin, 2)) = TabFin
End With
Application.ScreenUpdating = True
End Sub