|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Set d1 = CreateObject("scripting.dictionary")
- Set d2 = CreateObject("scripting.dictionary")
- With Worksheets("GZHZ")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- c = .Cells(1, .Columns.Count).End(xlToLeft).Column
- .Range("b2").Resize(r - 1, c - 1).ClearContents
- arr = .Range("a1").Resize(r, c)
- For i = 2 To UBound(arr)
- d1(arr(i, 1)) = i
- Next
- For j = 2 To UBound(arr, 2)
- d2(arr(1, j)) = j
- Next
- End With
- With Worksheets("GZ")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- brr = .Range("a2:g" & r)
- End With
- For i = 1 To UBound(brr)
- If d1.exists(brr(i, 1)) Then
- m = d1(brr(i, 1))
- arr(m, 2) = brr(i, 2)
- If d2.exists(brr(i, 4)) Then
- n = d2(brr(i, 4))
- arr(m, n) = brr(i, 5)
- arr(m, 16) = arr(m, 16) + brr(i, 6)
- End If
- End If
- Next
- For i = 2 To UBound(arr)
- For j = 3 To 16
- arr(i, 17) = arr(i, 17) + arr(i, j)
- Next
- arr(i, 18) = Application.Round(arr(i, 17) / 12, 0)
- Next
- With Worksheets("GZHZ")
- .Range("a1").Resize(UBound(arr), UBound(arr, 2)) = arr
- End With
- End Sub
复制代码 |
|