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
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: