|
代码更新,加个小计- Sub ykcbf() '//2024.7.31 总表按模板拆分为多表,加个小计
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- For Each sht In Sheets
- If Val(sht.Name) Then sht.Delete
- Next
- With Sheets("申购记录")
- r = .Cells(Rows.Count, 6).End(3).Row
- c = .UsedRange.Columns.Count
- arr = .[a1].Resize(r, c)
- End With
- For i = 2 To UBound(arr)
- s = FormatDateTime(arr(i, 1), 1)
- If Not d.exists(s) Then Set d(s) = CreateObject("Scripting.Dictionary")
- d(s)(i) = i
- Next
- On Error Resume Next
- For Each k In d.keys
- Sheets("模版").Copy After:=Sheets(Sheets.Count)
- Set sht = Sheets(Sheets.Count)
- m = 0
- With sht
- .[m2] = k
- .Name = k
- ReDim brr(1 To 1000, 1 To 14)
- For Each kk In d(k).keys
- m = m + 1
- For j = 2 To UBound(arr)
- brr(m, j - 1) = arr(kk, j)
- Next
- Next
- If m > 5 Then
- For i = 1 To m - 5
- .Cells(5 + i, 1).EntireRow.Insert
- Next i
- End If
- .[a4].Resize(m, 14) = brr
- r = .Columns.Find("汇总").Row
- .Cells(r, "k") = Application.Sum(.Cells(4, "l").Resize(m))
- End With
- Next
- Sheets("申购记录").Activate
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|