|
- Option Explicit
- Sub qq()
- Dim d, arr, r&, i&, brr(), n%, d1, s$
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- With Worksheets("sheet1")
- r = .Cells(.Cells.Rows.Count, "i").End(xlUp).Row
- arr = .Range("a2:ac" & r)
- For i = 1 To UBound(arr)
- If Not d.exists(arr(i, 9)) Then
- ReDim brr(1 To 28)
- brr(1) = arr(i, 9)
- Else
- brr = d(arr(i, 9))
- End If
- n = Month(arr(i, 29))
- brr(n * 2 + 2) = brr(n * 2 + 2) + (arr(i, 18) * arr(i, 22))
- brr(27) = brr(27) + brr(n * 2 + 2)
- s = arr(i, 9) & "+" & n & "+" & arr(i, 1)
- If Not d1.exists(s) Then
- d1(s) = ""
- brr(n * 2 + 1) = brr(n * 2 + 1) + 1
- brr(28) = brr(28) + 1
- End If
- d(arr(i, 9)) = brr
- Next
- End With
- With Sheet4
- .[a3].CurrentRegion.Offset(2).ClearContents
- .[b5].Resize(d.Count, 28) = Application.Transpose(Application.Transpose(d.items))
- End With
- End Sub
复制代码 |
|