I'm trying to make a data entry worksheet that has a macro button to make a copy of the sheet and save the data to it so as to retrieve it at a later time. This is the code I am working from currently, but I keep getting an error.
Any additions or changes that might cure my issue?
Code:
Sub Macro1()
'Step 1: Tell Excel what to do if error
On Error GoTo MyError
'Step 2: Add a sheet and name it
' Worksheets("Sheet2").Copy After:=Worksheets("Sheet3")
' ActiveSheet.Name = "Test"
' Exit Sub
Dim name As Variant
name = InputBox("Date as mm.dd.yyyy")
Set ws = Sheets("Sheet2")
ws.Copy After:=("Sheet3")
Set wsNew = Sheets(Sheets("Sheet3").Index + 1)
wsNew.name = name
'Step 3: If here, an error happened; tell the user
MyError:
MsgBox "There is already a sheet called that."
End Sub
Any additions or changes that might cure my issue?