VBA Copying Multiple Sheets and Renaming using a list

mwithers

New Member
Joined
Oct 23, 2013
Messages
4
Hi, I'm trying to set up a macro that copies over 2 tabs (named "Template Summary" & "Template Data") and renames the copied tabs based on a list (the list is on a tab called "Impacts"). The Summary tab is linked to the data tab and as such when they are copied I need the new summary tab to look up to the new data tab. I've done a macro that currently will copy over the each tab at a time but the trouble is it doesn't link up to the new data one, it links up to the original data tab.Sub CreateSheetsFromAList()
Dim ws1 As Worksheet
Set ws1 = ThisWorkbook.Worksheets("Template Summary")
Dim MyCell1 As Range, MyRange1 As Range
Set MyRange1 = Sheets("Impacts").Range("Q2")
Set MyRange1 = Range(MyRange1, MyRange1.End(xlDown))
For Each MyCell1 In MyRange1
ws1.Copy ThisWorkbook.Sheets(Sheets.Count)
ThisWorkbook.Worksheets("Template Summary (2)").Name = MyCell1.Value
Next MyCell1
End Sub
Sub CreateSheetsFromBList()
Dim ws2 As Worksheet
Set ws2 = ThisWorkbook.Worksheets("Template Data")
Dim MyCell2 As Range, MyRange2 As Range
Set MyRange2 = Sheets("Impacts").Range("R2")
Set MyRange2 = Range(MyRange2, MyRange2.End(xlDown))
For Each MyCell2 In MyRange2
ws2.Copy ThisWorkbook.Sheets(Sheets.Count)
ThisWorkbook.Worksheets("Template Data (2)").Name = MyCell2.Value
Next MyCell2
End Sub
Is what I'm trying to do possible? Thanks - I also have a macro for copying both at the same time so they link, but I'm struggling to them rename them both based on 2 lists.Sub Macro3()
'
' Macro3 Macro
'
'
Sheets(Array("Template Summary", "Template Data")).Select
Sheets(Array("Template Summary", "Template Data")).Copy Before:=Sheets(Sheets.Count)
End Sub
 
Last edited:

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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