Hi,
I have one master file with 3 sheets and I need to duplicate this workook 100 times and saving it based on a list of names. i'm hoping a macro can help me do this.
example:
sheet 1
sheet 2
sheet 3 - called sheetlist
in sheet 3 i have a list of names in collumn A
100
200
300
400
.
.
I need it to look at the list and rename sheet 2 to 100 and then do a savefile as 100. then this would continue down the list.
i started on a macro with a loop but it is not working please see below. hopefully someone can help me with my code
I have one master file with 3 sheets and I need to duplicate this workook 100 times and saving it based on a list of names. i'm hoping a macro can help me do this.
example:
sheet 1
sheet 2
sheet 3 - called sheetlist
in sheet 3 i have a list of names in collumn A
100
200
300
400
.
.
I need it to look at the list and rename sheet 2 to 100 and then do a savefile as 100. then this would continue down the list.
i started on a macro with a loop but it is not working please see below. hopefully someone can help me with my code
Code:
Sub Detailsummary()
Dim ws As Worksheet
Dim i As Long
Dim sname As String
Dim tname As String
Dim lastrow As Long
Dim ThisFile As String
Dim icostcentre As String
For i = 3 To Worksheets("sheetlist").Range("A" & Rows.Count).End(xlUp).Row + 1
'With Worksheets(i - 1)
sname = Worksheets("sheetlist").Range("A" & i - 1).Value
tname = Worksheets("sheetlist").Range("A" & i - 2).Value
Sheets(tname).Select
ActiveSheet.Name = sname
ThisFile = Worksheets("sheetlist").Range("A" & i - 1).Value
Application.DisplayAlerts = False
Worksheets("sheetlist").Delete
Application.DisplayAlerts = True
ThisWorkbook.SaveAs Filename:=ThisFile
'ActiveWorkbook.Close
'MsgBox ("sname" & sname)
'MsgBox ("tname" & tname)
'End With
Next i
End Sub