Re et re
Comme çà alors
Option Explicit
Sub test()
Dim a, i As Long, dico As Object
Set dico = CreateObject("Scripting.Dictionary")
dico.CompareMode = 1
a = Sheets("stock").Range("a1").CurrentRegion.Value
For i = 2 To UBound(a, 1)
If Not dico.exists(a(i, 1)) Then
Set dico(a(i, 1)) = CreateObject("System.Collections.ArrayList")
End If
If Not dico(a(i, 1)).contains(a(i, 2)) Then
dico(a(i, 1)).Add a(i, 2)
End If
Next
With Sheets("plan").Range("a1").CurrentRegion
a = .Value
For i = 2 To UBound(a, 1)
If Not IsEmpty(a(i, 3)) Then
If dico.exists(a(i, 2)) Then
If dico(a(i, 2)).Count Then
If dico(a(i, 2)).contains(a(i, 3)) Then
dico(a(i, 2)).removeat dico(a(i, 2)).Indexof(a(i, 3), 0)
End If
End If
End If
End If
Next
For i = 2 To UBound(a, 1)
If dico.exists(a(i, 2)) And IsEmpty(a(i, 3)) Then
If dico(a(i, 2)).Count Then
a(i, 3) = dico(a(i, 2))(0)
dico(a(i, 2)).removeat 0
End If
End If
Next
.FormulaLocal = a
End With
Set dico = Nothing
End Sub
klin89