Private Sub CommandButton1_Click()
On Error Resume Next
Application.DisplayAlerts = False
Sheet1.Copy Sheets(Sheets.Count)
ActiveSheet.Name = TextBox1 'InputBox("请输入新建表格名字", "")
If ActiveSheet.Name <> TextBox1.Value Then
MsgBox "【 " & TextBox1.Value & " 】已存在!"
ActiveSheet.Delete
End If
Application.DisplayAlerts = True
End Sub
Private Sub CommandButton1_Click()
On Error Resume Next
Application.DisplayAlerts = False
Sheet1.Copy Sheets(Sheets.Count)
ActiveSheet.Name = TextBox1 'InputBox("请输入新建表格名字", "")
If ActiveSheet.Name <> TextBox1.Value Then
MsgBox "【 " & TextBox1.Value & " 】已存在!"
ActiveSheet.Delete
End If
Application.DisplayAlerts = True
End Sub
Private Sub CommandButton1_Click()
Dim ws As Worksheet
Dim sName As String
sName = TextBox1
On Error Resume Next
Set ws = Sheets(sName)
If ws Is Nothing Then '指定的工作表不存在
Sheets.Add.Name = sName
Else '指定的工作表已存在
MsgBox "“" & sName & "”工作表已存在。"
ws.Activate
End If
End Sub