Replicating Worksheets

tjc154

Active Member
Joined
Apr 7, 2007
Messages
363
I'm using the following macro to create multiple worksheets.

Code:
Sub ReplicateSheets()
Dim i As Integer
    For i = 1 To 20
        Sheets("Game").Copy after:=Worksheets(Worksheets.Count)
        
    Next
End Sub
–this follows the code

I would like the macro to append the subsequent sheet names as follows: Game 1, Game 2, Game 3, Game 4, etc. Currently it puts a number in brackets after the name to indicate its a duplicate sheet.

How do I adjust the code to achieve the desired results?

Thanks,

Tom
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Like this perhaps

Code:
Sub ReplicateSheets()
Dim i As Integer
    For i = 1 To 20
        Sheets("Game").Copy after:=Worksheets(Worksheets.Count)
        ActiveSheet.Name = "Game " & i
    Next
End Sub
 
Upvote 0
I'm looking for some code that does something similar.

I have a worksheet called "product" which contains 45 unique productcodes in cells A1:A45, and I want the code to create a duplicate of a worksheet called "source" for each product, change the name of the new worksheet to the productcode and enter the productcode in cell A1.

Can you help me?
 
Upvote 0
Assuming you have a header row in the Products sheet

Code:
Sub splitproducts()
Dim shProd As Worksheet: Set shProd = Sheets("Products")
Dim shSrc As Worksheet: Set shSrc = Sheets("Source")
Dim Products As Long: Products = shProd.Range("A" & Rows.Count).End(xlUp).Row
Dim i As Long
For i = 2 To Products
    shSrc.Copy After:=Sheets(Sheets.Count)
    With ActiveSheet
        .Name = shProd.Range("A" & i)
        .Range("A1").Value = shProd.Range("A" & i)
    End With
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

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