|
- Sub qs()
- Dim arr, brr, i, dic, s
- Set dic = CreateObject("scripting.dictionary")
- With Sheet2
- r2 = .Cells(Rows.Count, 4).End(3).Row
- arr = .Range("d1").Resize(r2, 2).Value
- End With
- For i = 2 To UBound(arr)
- s = arr(i, 1)
- If Not dic.exists(s) Then
- dic(s) = arr(i, 2)
- Else
- dic(s) = dic(s) + arr(i, 2)
- End If
- Next
- With Sheet1
- r = .Cells(Rows.Count, 2).End(xlUp).Row
- brr = .Range("b1").Resize(r, 2).Value
- For i = 2 To UBound(brr)
- If dic.exists(brr(i, 1)) Then
- brr(i, 2) = dic(brr(i, 1))
- End If
- Next
- .Range("k1").Resize(10000, 1).ClearContents
- brr(1, 2) = "入库数"
- .Range("k1").Resize(UBound(brr), 1) = Application.Index(brr, 0, 2)
- End With
- End Sub
复制代码 |
|