本帖最后由 笑着...两年过去 于 2015-9-25 16:24 编辑
- Sub test()
- Dim dc As Object, arr, yrr, brr(), i
- Set dc = CreateObject("scripting.dictionary")
- arr = [j1].CurrentRegion
- yrr = Range("d2:f" & Range("d65536").End(3).Row)
- ReDim brr(1 To UBound(yrr), 1 To 2)
- For i = 2 To UBound(arr)
- dc(arr(i, 1)) = dc(arr(i, 1)) + arr(i, 2)
- Next
- For i = 1 To UBound(yrr)
- If dc.exists(yrr(i, 1)) Then brr(i, 1) = dc(yrr(i, 1)): dc(yrr(i, 1)) = dc(yrr(i, 1)) - yrr(i, 3): brr(i, 2) = dc(yrr(i, 1))
- Next
- [g2].Resize(UBound(yrr), 2) = brr
- End Sub
复制代码 |