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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

dave3009

Well-known Member
Joined
Jun 23, 2006
Messages
7,128
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
  2. Mobile
  3. Web
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

Sander2309

New Member
Joined
Mar 31, 2011
Messages
1
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

dave3009

Well-known Member
Joined
Jun 23, 2006
Messages
7,128
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
  2. Mobile
  3. Web
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,191,485
Messages
5,986,861
Members
440,055
Latest member
CraigTriesHisBest

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
Top