学习一下字典,打扰了
Sub test()
arr = Sheet2.[a4].CurrentRegion
Set d = CreateObject("scripting.dictionary")
For i = 3 To UBound(arr)
If arr(i, 1) <> "" Then
d(arr(i, 1)) = d(arr(i, 1)) + arr(i, 2)
End If
Next
brr = Sheet1.[a1].CurrentRegion
For i = 4 To UBound(brr)
brr(i, 4) = d(brr(i, 2))
Next
Sheet1.[a1].CurrentRegion = brr
End Sub