|
- Sub ykcbf() '//2025.3.25 多表拆分为多工作簿多表
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- Dim tm: tm = Timer
- Set ws = ThisWorkbook
- p = ThisWorkbook.Path & ""
- On Error Resume Next
- col = 1: bt = 1
- For Each sht In ws.Sheets
- arr = sht.UsedRange
- For i = bt + 1 To UBound(arr)
- If arr(i, col) <> Empty Then d(arr(i, col)) = ""
- Next
- Next
- For Each k In d.keys
- ws.Sheets.Copy
- Set wb = ActiveWorkbook
- For Each sht In wb.Sheets
- With sht
- If .FilterMode = True Then .ShowAllData
- arr = .UsedRange
- .DrawingObjects.Delete
- .Rows(bt).AutoFilter Field:=col, Criteria1:="<>" & k
- .UsedRange.Offset(bt).Delete
- If .FilterMode = True Then .ShowAllData
- End With
- Next
- wb.SaveAs p & k
- wb.Close
- Next
- Application.ScreenUpdating = True
- Application.DisplayAlerts = True
- MsgBox "共用时:" & Format(Timer - tm, "0.000") & "秒!"
- End Sub
复制代码
|
|