本帖最后由 yaozong 于 2013-8-21 07:14 編輯 lxljw1314 發(fā)表于 2013-8-20 22:08
附件上傳了,在你的附件基礎(chǔ)上修改的
Private Sub CommandButton1_Click()
Dim d, ar, arr, s$, t$, i&
Set d = CreateObject("Scripting.Dictionary")
ar = Range("b2", [b65536].End(3).Offset(, 5)).Value
arr = Sheet2.Range("b2", Sheet2.[j65536].End(3)).Value
For i = 1 To UBound(arr)
t = Join(Application.Index(Application.Index(arr, i, 0), Array(1, 2, 3, 4)), ",")
d(t) = d(t) + arr(i, 9)
Next
For i = 1 To UBound(ar)
s = Join(Application.Index(Application.Index(ar, i, 0), Array(1, 2, 3, 4)), ",")
If d.exists(s) Then ar(i, 5) = d(s) Else ar(i, 5) = ""
Next
[b2].Resize(UBound(ar), UBound(ar, 2)) = ar
Set d = Nothing
End Sub