Objective: I would like to ask the user if when the name the worksheet the same as an already existing spreadsheet tabe if they would like to overwrite it or unload the user form.
I am not sure of two things:
1. how to find the already existing tab?
2. Once I find out how do I programatically delete it, so the code can continue
I appreciate your help in advance.
The code below works with the exception of the last section (trying to achieve the questions stated above).
I am using Excel 2010.
I am not sure of two things:
1. how to find the already existing tab?
2. Once I find out how do I programatically delete it, so the code can continue
I appreciate your help in advance.
The code below works with the exception of the last section (trying to achieve the questions stated above).
I am using Excel 2010.
Code:
Private Sub CommandButton1_Click()
If TextBox1.Value = blank Then 'Need name for processing
MsgBox ("Name must not be blank.")
Exit Sub
End If
If Len(TextBox1.Value) > 12 Then
MsgBox ("Name must be no more than 12 characters.")
Exit Sub
End If
If TextBox1.Value Like "*:*" Then
MsgBox ("Name must not usual special characters like : \ / ? [ ].")
Exit Sub
End If
If TextBox1.Value Like "*\*" Then
MsgBox ("Name must not usual special characters like : \ / ? [ ].")
Exit Sub
End If
If TextBox1.Value Like "*/*" Then
MsgBox ("Name must not usual special characters like : \ / ? [ ].")
Exit Sub
End If
If TextBox1.Value Like "*?*" Then
MsgBox ("Name must not usual special characters like : \ / ? [ ].")
Exit Sub
End If
If TextBox1.Value Like "*[*" Then
MsgBox ("Name must not usual special characters like : \ / ? [ ].")
Exit Sub
End If
If TextBox1.Value Like "*]*" Then
MsgBox ("Name must not usual special characters like : \ / ? [ ].")
Exit Sub
End If
Columns(1).Insert
For i = 1 To Sheets.Count
Cells(i, 1) = Sheets(i).Name
Next i
'Here is where I need help
If TextBox1 & " " & Range("P1") = Sheets(i).Name Then
MsgBox ("Duplicate name cannot exist.")
End If
Exit Sub