|
Sub zy()
Dim brr()
zdh = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
arr = Sheet1.Range("a1:e" & zdh)
Set dic = CreateObject("scripting.dictionary")
For i = 2 To UBound(arr)
Key = arr(i, 2) & ""
If Not dic.exists(Key) Then
k = k + 1
dic(Key) = k '给一个人一个序号,第一个人是1,第二个人是2
End If
ReDim Preserve brr(1 To UBound(arr), 1 To 32)
行 = k
列 = Format(arr(i, 3), "d") + 1
brr(行, 1) = Key & ""
brr(行, 列) = arr(i, 4)
brr(行, 32) = "=sum(RC[-30]:RC[-1])"
Next
With Sheet2
For xx = 5 To .UsedRange.Row
m = m + 1
.Range("b" & xx).Resize(1, UBound(brr, 2)) = Application.Index(brr, m, 0)
If m Mod 15 = 0 Then
xx = xx + 7
End If
If m > k Then Exit Sub
Next
End With
Set dic = Nothing
MsgBox "完成!"
End Sub |
|