I am trying to make a macro that accepts a date from a user. The macro then creates a worksheet and names it the date. The problem that I have is that some users enter in one of the symbols that is restricted when naming worksheets. I have used a errorhandler routine and it works the first time, but does not work if the user reenters the improper date. How can I fix this? The code is as follows. Thanks in advance.
Sub New_month()
Application.ScreenUpdating = False
On Error GoTo errorhandler
Dim startingdate As String
Dim num As Integer
startingdate = InputBox("Please enter the starting date for the new schedule! Please enter in month date format. (ie. 2-10)")
num = Sheets.Count
Sheets("Master").Unprotect
Sheets("Master").Copy After:=Sheets(num)
Sheets("Master").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets(num + 1).Select
start:
range("g1").Select
ActiveCell = startingdate
range("g3").Select
Sheets(num + 1).Name = startingdate
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Exit Sub
errorhandler:
MsgBox ("Please do not use any symbols other than - for the date")
startingdate = InputBox("Please enter the starting date for the new schedule! Please enter in month date format. (ie. 2-10)")
GoTo start
End Sub
Sub New_month()
Application.ScreenUpdating = False
On Error GoTo errorhandler
Dim startingdate As String
Dim num As Integer
startingdate = InputBox("Please enter the starting date for the new schedule! Please enter in month date format. (ie. 2-10)")
num = Sheets.Count
Sheets("Master").Unprotect
Sheets("Master").Copy After:=Sheets(num)
Sheets("Master").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets(num + 1).Select
start:
range("g1").Select
ActiveCell = startingdate
range("g3").Select
Sheets(num + 1).Name = startingdate
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Exit Sub
errorhandler:
MsgBox ("Please do not use any symbols other than - for the date")
startingdate = InputBox("Please enter the starting date for the new schedule! Please enter in month date format. (ie. 2-10)")
GoTo start
End Sub