|
参与一下。。。- Sub ykcbf() '//2024.1.18
- Dim wb, arr, sh
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- p = ThisWorkbook.Path & ""
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set d = CreateObject("Scripting.Dictionary")
- st = "网元割接数据发布模板"
- Set sh = ThisWorkbook.Sheets("Sheet1")
- With sh
- r = .Cells(Rows.Count, "k").End(3).Row
- arr = .Range("a1:w" & r)
- End With
- For i = 2 To UBound(arr)
- s = arr(i, 11)
- If Not d.exists(s) Then Set d(s) = CreateObject("Scripting.Dictionary")
- d(s)(i) = i
- Next
- For Each k In d.keys
- sh.Copy
- Set wb = ActiveWorkbook
- m = 0
- p1 = p & k & ""
- If Not fso.FolderExists(p1) Then fso.CreateFolder p1
- ReDim brr(1 To d(k).Count, 1 To UBound(arr, 2))
- With wb.Sheets(1)
- .Name = k
- .DrawingObjects.Delete
- .UsedRange.Offset(1 + d(k).Count).Clear
- For Each kk In d(k).keys
- m = m + 1
- For j = 1 To UBound(arr, 2)
- brr(m, j) = arr(kk, j)
- Next
- Next
- .[a2].Resize(m, UBound(arr, 2)) = brr
- End With
- wb.SaveAs p1 & st, 56
- wb.Close 1
- Next
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|