My code is as below:
Sub NewWorksheetTest()
Dim wsname As String
wsname = InputBox("Enter a name for the new worksheet")
On Error GoTo BadEntry
Sheets.Add
ActiveSheet.Name = wsname
Exit Sub
BadEntry:
MsgBox Err.Number & " :"& Err.Description, vbInformation, "There is an error...."
End Sub
My understanding is when i input something bad(e.g.duplicated names or names containing ?/), there is a message explaining the reasons and at the same time system stops a new sheet from being added. However when I try, the error msg is there but a new sheet keeps on being added to the workbook. Can anyone solve this please?:)