Saving data entry sheet to a copy with in a workbook

sokkaiya

New Member
Joined
Jun 15, 2018
Messages
2
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.

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?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hi & welcome to the board.
How about
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:=[COLOR=#ff0000]Sheets[/COLOR]("Sheet3")
    Set wsNew = Sheets(Sheets("Sheet3").Index + 1)
    wsNew.name = name
[COLOR=#ff0000]Exit Sub[/COLOR]

'Step 3: If here, an error happened; tell the user
MyError:
    MsgBox "There is already a sheet called that."
End Sub
 
Upvote 0
Ok... Well that worked like all my other attempts. It didn't. There is stall an error somewhere that I am not picking up. I retyped the code and tried it again, I have done a bit more googling, and still have yet to some up with a suitable answer.

The whole premise of this is to be able to input data into a data entry sheet, it save it into a new sheet that then can be referenced by another sheet by name, in this case date. I am trying to avoid using a workbook for each date, but I do need to separate each set of data by date.

Any suggestions and/or clarifications on how I might be able to accomplish this in a single workbook?
 
Upvote 0
Remove this line of code
Code:
On Error GoTo MyError
and run the code again, what error message do you get & what line is highlighted when you click debug?
 
Upvote 0

Forum statistics

Threads
1,223,958
Messages
6,175,636
Members
452,662
Latest member
Aman1997

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top