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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
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,214,545
Messages
6,120,132
Members
448,947
Latest member
test111

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