|
总表拆分- Sub ykcbf() '//2024.9.12
- Dim wb, arr, sh
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim tm: tm = Timer
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set d = CreateObject("Scripting.Dictionary")
- p = ThisWorkbook.Path & ""
- Set ws = ThisWorkbook
- Set sh = ws.Sheets("数据")
- On Error Resume Next
- arr = sh.UsedRange
- For i = 2 To UBound(arr)
- If arr(i, 1) <> Empty Then
- s = CStr(arr(i, 6))
- If Not d.exists(s) Then Set d(s) = CreateObject("Scripting.Dictionary")
- d(s)(i) = i
- End If
- Next
- For Each k In d.keys
- Sheets("统计表").Copy
- Set wb = ActiveWorkbook
- m = 0
- ReDim brr(1 To d(k).Count, 1 To UBound(arr, 2))
- With wb.Sheets(1)
- .Name = k
- .[d3] = k
- For Each kk In d(k).keys
- m = m + 1
- brr(m, 1) = m
- brr(m, 2) = arr(kk, 1)
- brr(m, 3) = arr(kk, 12)
- brr(m, 4) = "同意支付" & arr(kk, 10) & arr(kk, 5) & "元,该笔款项为我行" & arr(kk, 2) & "的费用,列支“" & arr(kk, 11) & "”科目。"
- jg = arr(kk, 1)
- Next
- .[a5].Resize(m, 4) = brr
- End With
- wb.SaveAs p & jg & k
- wb.Close
- Next
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "拆分完毕,共用时:" & Format(Timer - tm) & "秒!"
- End Sub
复制代码
|
|