Macro to Open new tab and duplicate the data from the template, and rename new tab from cell value of template.

Brockker

New Member
Joined
Jun 13, 2024
Messages
2
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Greetings fellow gurus. I am trying to help my 11 yr old daughter with her passion for baking and making pastries. I am fairly knowledgable with working with formulas and all, but when it comes to macros.... let's just say I'm not your best plumber if in need of a doctor lol. I created a worksheet template named "Blank". In the template, I added a a squared symbol titled duplicate sheet, that has the sole purpose of adding a new blank tab (via macro recording assigned to the square) whenever my daughter wants to add a new recipe. I've been searching for a bit, but now I'm stumped without a solution. Although I've seen macros somewhat related to the topic, they just don't do exactly what I'm trying to accomplish as they only renamed the templates tab, in the cases that I have tried it and not the new one. I would like the macro to do the following once my daughter clicks on the squared symbol to create a new tab:

1- I would like the macro to rename the NEW Tab with the recipe name that she will type in cell B1 from the "Blank" template
2- once the new tab is renamed to the recipe's name, I would like it to duplicate the template's data onto newly renamed tab keeping all of the same format (without the squared symbol)

I am also open to any other suggestions if there is any other simpler solution to accomplish what I am trying to achieve. Thanks.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Assign this macro to the square symbol.
VBA Code:
Sub CreateNewSheet()
    Application.ScreenUpdating = False
    Dim wsName As String
    wsName = Range("B1").Value
    ActiveSheet.Copy after:=ActiveSheet
    With ActiveSheet
        .Name = wsName
        .Shapes(1).Delete
    End With
    Application.ScreenUpdating = True
End Sub
 
Upvote 1
Solution
Sub CreateNewSheet()
Application.ScreenUpdating = False
Dim wsName As String
wsName = Range("B1").Value
ActiveSheet.Copy after:=ActiveSheet
With ActiveSheet
.Name = wsName
.Shapes(1).Delete
End With
Application.ScreenUpdating = True
End Sub


Thank you so much mumps, that actually worked as I was envisioning it. Thanks to you now I will look like a super dad to my daughter. Super happy to start seeing her use it.
 
Upvote 0

Forum statistics

Threads
1,223,881
Messages
6,175,159
Members
452,615
Latest member
bogeys2birdies

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