Creating new sheet in workbook that is the same as an active sheet

Simmo1313

New Member
Joined
May 4, 2015
Messages
39
Hi All,

I have a workbook that has a master project worksheet page ("MAIN") that is a summary of all individual projects worksheets.

On the main page I want to assign code to a button that will add a new worksheet that is a copy of a template worksheet within the same workbook ("TEMPLATE").

For ease references within the main worksheet it would be preferable if the new page could also be named within this macro and positioned at the end of the worksheet tabs.

Thanks in advance
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
You could have simply recorded a macro to do this

Code:
Sub MM1()
    Sheets("TEMPLATE").Copy After:=Sheets(Sheets.Count)
    ActiveSheet.Name = "copy of template"
End Sub
 
Upvote 0
Yes but that does not enable me to name the sheet as well.

I found some code that enables me to name the new sheet, is there a way of combining the recorded macro with this code so that I can create a new sheet, name it and have it duplicate the TEMPLATE

Sub AddNameNewSheet1()
Dim Newname As String
Newname = InputBox("Name for new worksheet?")
If Newname <> "" Then
Sheets.Add Type:=xlWorksheet
ActiveSheet.Name = Newname
End If
End Sub
 
Upvote 0
Use

Code:
Sub MM1()
Dim ans As String
ans = InputBox("Please provide the NEW Sheet Name")
Sheets("TEMPLATE").Copy After:=Sheets(Sheets.Count)
    ActiveSheet.Name = ans
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,892
Messages
6,175,236
Members
452,621
Latest member
Laura_PinksBTHFT

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