Bonsoir à tous,
Une version VBA simplement
Option Explicit
Sub test()
Dim a, w(), i As Long, dico As Object
Set dico = CreateObject("Scripting.Dictionary")
dico.CompareMode = 1
dico("a") = Array("Données totales", "Ecart")
With Sheets("Feuil1")
a = .Range("d6").CurrentRegion.Value
For i = 2 To UBound(a, 1)
dico(a(i, 1)) = Array(a(i, 1), a(i, 2))
Next
a = .Range("g6").CurrentRegion.Value
For i = 2 To UBound(a, 1)
If dico.exists(a(i, 1)) Then
w = dico(a(i, 1))
Else
ReDim w(0 To 1)
w(0) = a(i, 1)
End If
w(1) = w(1) - a(i, 2)
dico(a(i, 1)) = w
Next
With .Range("k6")
.CurrentRegion.ClearContents
With .Resize(dico.Count, UBound(Application.Index(dico.items, 0, 0), 2))
.Value = Application.Index(dico.items, 0, 0)
End With
End With
End With
Set dico = Nothing
End Sub
Attention aux espaces superflus en fin de chaine
klin89