|
- Sub hz()
- '汇总
- Dim Sh As Worksheet
- Set Sh = Sheets(Sheet6.Name)
- Sheet3.Range("a2:l30").ClearContents
- Dim d As New Dictionary
- Dim lR%
- lR = Sh.Range("A65536").End(xlUp).Row
- Dim lC%
- lC = Sh.Range("IV1").End(xlToLeft).Column
- Dim Arr, Brr()
- Arr = Sh.Range(Sh.Cells(2, 1), Sh.Cells(lR, lC))
- ReDim Brr(1 To UBound(Arr, 1), 1 To UBound(Arr, 2))
- Dim i%, j%, k%, l%
- k = 1
- For i = 1 To UBound(Arr, 1)
- If Not d.Exists(Arr(i, 1)) Then
- d(Arr(i, 1)) = k
- For j = 1 To UBound(Arr, 2)
- Brr(d(Arr(i, 1)), j) = Arr(i, j)
- Next
- k = k + 1
- Else
- For j = 1 To UBound(Arr, 2)
- If j < 3 Then
- Brr(k, j) = Arr(i, j)
- Else
- Brr(d(Arr(i, 1)), j) = Brr(d(Arr(i, 1)), j) + Arr(i, j)
- End If
- Next
-
- End If
-
- Next
-
-
- Sheet3.Cells(2, 1).Resize(UBound(Brr, 1), UBound(Brr, 2)) = Brr
-
-
-
-
-
- End Sub
复制代码 |
|