|
参与一下。。。
- Sub ykcbf2() '//2024.4.1
- 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 = 3 '//标题行数
- col = 3 '//拆分列号
- For i = bt + 1 To UBound(arr)
- s = arr(i, col)
- If InStr(s, "汇总") = 0 And s <> Empty Then
- If Not d.exists(s) Then Set d(s) = CreateObject("Scripting.Dictionary")
- d(s)(i) = i
- End If
- Next
- On Error Resume Next
- For Each k In d.keys
- sh.Copy
- Set wb = ActiveWorkbook
- m = 0
- ReDim brr(1 To d(k).Count + 1, 1 To UBound(arr, 2))
- With wb.Sheets(1)
- .Name = k
- .DrawingObjects.Delete
- .UsedRange.Offset(bt + d(k).Count + 1).Clear
- For i = 4 To UBound(arr)
- If InStr(arr(i, 3), k) Then
- m = m + 1
- For j = 1 To UBound(arr, 2)
- brr(m, j) = arr(i, j)
- Next
- End If
- Next
- .Cells(bt + 1, 1).Resize(m, UBound(arr, 2)) = brr
- End With
- wb.SaveAs p & k
- wb.Close 1
- Next
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|