|
参与一下。。。
- Sub ykcbf() '//2024.5.25 总表拆分为多工作簿
- Dim wb, arr, sh
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- p = ThisWorkbook.Path & ""
- Set d = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("汇总表")
- arr = sh.UsedRange
- bt = 1 '//标题行数
- col = 6 '//拆分列号
- For i = bt + 1 To UBound(arr)
- s = arr(i, col)
- If Not d.exists(s) Then Set d(s) = CreateObject("Scripting.Dictionary")
- d(s)(i) = Application.Index(arr, i)
- Next
- For Each k In d.keys
- sh.Copy
- Set wb = ActiveWorkbook
- m = d(k).Count
- With wb.Sheets(1)
- .Name = k
- .DrawingObjects.Delete
- .UsedRange.Offset(bt + m).Clear
- .Columns(4).NumberFormatLocal = "@"
- .Cells(bt + 1, 1).Resize(m, UBound(arr, 2)) = Application.Rept(d(k).Items, 1)
- End With
- wb.SaveAs p & k
- wb.Close 1
- Next
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|