- Sub qs()
- Dim arr, i, dic
- Set dic = CreateObject("scripting.dictionary")
- arr = Sheet1.UsedRange.Value
- For i = 2 To UBound(arr)
- s = arr(i, 3)
- If Not dic.exists(s) Then
- dic(s) = Array(arr(i, 9), arr(i, 12), arr(i, 13))
- Else
- dic(s) = Array(dic(s)(0) + arr(i, 9), dic(s)(1) + arr(i, 12), dic(s)(2) + arr(i, 13))
- End If
- Next
- brr = Sheet2.UsedRange.Value
- For i = 2 To UBound(brr)
- s = brr(i, 4)
- If dic.exists(s) Then
- ar = dic(s)
- For j = 0 To 2
- brr(i, j + 8) = ar(j)
- Next
- End If
- Next
- Sheet2.Range("a3").Resize(UBound(brr), UBound(brr, 2)) = brr
- End Sub
复制代码 |