|
参与一下。。。- Sub 按一级部门拆分() '//2024.3.12
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim t: t = Timer
- Set d = CreateObject("scripting.dictionary")
- Set ws = ThisWorkbook
- p = ThisWorkbook.Path & ""
- For Each sht In ws.Sheets
- Arr = sht.UsedRange
- For i = 2 To UBound(Arr)
- s = Trim(Arr(i, 1))
- If s <> "" Then d(s) = ""
- Next i
- Next sht
- For Each k In d.keys
- ws.Sheets.Copy
- Set wb = ActiveWorkbook
- For Each sht In Sheets
- With sht
- .DrawingObjects.Delete
- .AutoFilterMode = False
- r = .Cells(Rows.Count, 1).End(3).Row
- .Rows(1 & ":" & 1).AutoFilter
- .Range("A1").AutoFilter Field:=1, Criteria1:="<>" & k
- .Range(.Cells(2, 1), .Cells(r, 1)).EntireRow.Delete
- .AutoFilterMode = False
- End With
- Next
- wb.SaveAs p & k
- wb.Close
- Next k
- Set d = Nothing
- Application.ScreenUpdating = True
- Application.DisplayAlerts = True
- MsgBox "拆分完毕,共用时: " & Format(Timer - t, "0.000秒"), , "提示"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|