|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub sc() '单独增加ABC工作表
Dim sht As Worksheet, st As Worksheet
k = 0
For Each sht In Sheets
If sht.Name = "ABC" Then
k = k + 1
MsgBox "ABC工作表已经存在 "
End If
Next
If k = 0 Then
Set st = Sheets.Add
st.Name = "ABC"
End If
End Sub
Sub dl() '删除加增加ABC工作表
Application.DisplayAlerts = False
Dim sht As Worksheet, k, st As Worksheet
k = 0
arr = Array("ABC", "01", "02", "03", "04")
Set dic = CreateObject("scripting.dictionary")
For i = 0 To UBound(arr)
dic(arr(i)) = 1
Next
For Each sht In Sheets
If dic(sht.Name) Then
If sht.Name = "ABC" Then k = k + 1
Else
sht.Delete
End If
Next
If k = 0 Then
Set st = Sheets.Add
st.Name = "ABC"
End If
Application.DisplayAlerts = True
End Sub |
|