OK, try again
Sub ertert()
Dim x, i&, j&, ubx&
x = Range("A1:B" & Cells(Rows.Count, 1).End(xlUp).Row).Value
With CreateObject("Scripting.Dictionary")
.CompareMode = 1
For i = 2 To UBound(x): .Item(x(i, 1)) = x(i, 2): Next i
ubx = UBound(x) + 1
x = Range("J1", Cells(1, Columns.Count).End(xlToLeft)).Resize(ubx).Value
For i = 1 To UBound(x, 2): x(ubx, i) = 0: Next i
For i = 2 To UBound(x) - 1 '2
For j = 1 To UBound(x, 2)
If .Exists(x(i, j)) Then x(i, j) = .Item(x(i, j))
x(ubx, j) = x(ubx, j) + x(i, j)
Next j
Next i
End With
Range("J1").Resize(UBound(x), UBound(x, 2)).Value = x
End Sub
Bookmarks