As Tim Williams said, On Error GoTo BadEntry only works when the error appears, and sheets.add has no error so it will run normally.
This is another version you can use
vs1-no error checking
Option Compare Text
Sub NewWorksheetTest()
Dim wsname As String
wsname = InputBox("Enter a name for the new worksheet")
If Not (Checks_Sheetname (wsname)) Then Exit Sub 'check correct name
If Check_SheetExists(wsname) Then Exit Sub 'check dulicate
Sheets.Add
ActiveSheet.Name = wsname
End Sub
'https://learn.microsoft.com/en-us/office/vba/excel/concepts/workbooks-and-worksheets/name-a-worksheet-by-using-a-cell-value
Private Function Checks_Sheetname (wsname As String) As Boolean
If Len(wsname) > 31 Then Checks_Sheetname = False:exit function 'check sheetname length
Dim lst_str As Variant, item As Variant
lst_str = Array("/", "\", "[", "]", "*", "?", ":")
For Each item In lst_str
If InStr(wsname, item) > 0 Then
'...
Checks_Sheetname = False: Exit Function
End If
Next item
Checks_Sheetname = True
End Function
'https://stackoverflow.com/questions/6688131/test-or-check-if-sheet-exists
Private Function Check_SheetExists(wsname As String) As Boolean
For Each ws In Worksheets
If wsname = ws.Name Then
MsgBox ("exist")
Check_SheetExists = True
Exit Function
End If
Next ws
End Function
vs2: error checking
Sub NewWorksheetTest()
Dim wsname As String
wsname = InputBox("Enter a name for the new worksheet")
On Error GoTo BadEntry
Dim Act_wsname As String: Act_wsname = ActiveSheet.Name
ActiveSheet.Name = wsname: ActiveSheet.Name = Act_wsname 'checksyntax
Dim ws As Worksheet: Set ws = Sheets(wsname) 'check dulicate
If Not (ws Is Nothing) Then Exit Sub
Sheets.Add
ActiveSheet.Name = wsname
Exit Sub
BadEntry:
MsgBox Err.Number & " :" & Err.Description, vbInformation, "There is an error...."
End Sub