I have a userform that has the user input a worksheet name, which I wave to the variable BorName. I have one IF statement to find out if the worksheet already exists. If it does exists then I want a messagebox thrown and want it to retry or cancel. The second IF statement just allows the sheet to be created if it is NOT already present. The problem I'm having is when it gets to the msgbox it tells me "Compile Error: Expected: =".
Essentially when the message box comes up and the user presses retry, then I want it to go back to that userform to try and put another worksheet name in until a nonexistent name is entered.
thanks for any help,
Essentially when the message box comes up and the user presses retry, then I want it to go back to that userform to try and put another worksheet name in until a nonexistent name is entered.
thanks for any help,
Code:
Sub MIPtab()
Dim WSName As String
Dim NextRow As Integer
Dim BorName As String
Dim k As Integer
Dim s As Integer
BorName = BoringName.Value
For s = 1 To Worksheets.Count
If Worksheets(s).Name = BorName = True Then
MsgBox(BorName & " already exists", vbRetryCancel, "Vironex Information")
Exit For
End If
Next s
For k = 1 To Worksheets.Count
If Worksheets(k).Name = BorName = False Then
Worksheets.Add(After:=Sheets(Sheets.Count)).Name = BorName
Exit For
End If
Next k