Excel批量删除指定关键字Sheet名称的工作表,助力办公效率提升
Excel情报局
Excel职场联盟
01
删除所有工作表
Excel情报局
02
删除指定关键字的工作表
Excel情报局
03
步骤讲解
Excel情报局
首先提取所有工作表名称到A列一列中显示。右击工作表,点击查看代码,将下面一段代码复制粘贴到VBA代码窗口。
代码如下:
Sub GetShtByVba()
Dim sht As Worksheet, k As Long
Application.ScreenUpdating = False
k = 1
Range("a:b").Clear
Range("a:a").NumberFormat = "@"
For Each sht In Worksheets
k = k + 1
Cells(k, 1) = sht.Name
Next
Range("a1:b1") = Array("名称", "删除")
Application.ScreenUpdating = True
End Sub
结果如下图所示:
Sub DelShtByVba()
Dim sht As Worksheet, i As Long, r
Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error Resume Next
r = Range("a1").CurrentRegion
For i = 2 To UBound(r)
If r(i, 2) = "删除" Then Worksheets(CStr(r(i, 1))).Delete
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
阅读完文章之后,希望小伙伴们在文章底部帮小编点亮[在看]并分享转发到[朋友圈],坚持持续分享的路上需要有你们的鼓励与支持!
赞 (0)