Hello!
I am using the code below to create excel workbook from a template and have it named according to the list. Is there a way to add on to the code to also have it put the newly named files into the corresponding folder from an adjacent cell? Files names would be in A1:A100 and Folder names in B1:B100.
Examples: The code saves templates with the specific names from tab "Name Index" position A1:A100 and places it in the matching folder name in position B1:B100.
I am using the code below to create excel workbook from a template and have it named according to the list. Is there a way to add on to the code to also have it put the newly named files into the corresponding folder from an adjacent cell? Files names would be in A1:A100 and Folder names in B1:B100.
Examples: The code saves templates with the specific names from tab "Name Index" position A1:A100 and places it in the matching folder name in position B1:B100.
VBA Code:
Public Sub SaveTemplate()
Const strSavePath As String = "C:\My Documents\"
Const strTemplatePath As String = "C:\My Documents\template.xls"
Dim rngNames As Excel.Range
Dim rng As Excel.Range
Dim wkbTemplate As Excel.Workbook
Set rngNames = ThisWorkbook.Worksheets("Name Index").Range("A1:A100").Values
Set wkbTemplate = Application.Workbooks.Open(strTemplatePath)
For Each rng In rngNames.Cells
wkbTemplate.SaveAs strSavePath & rng.Value
Next rng
wkbTemplate.Close SaveChanges:=False
End Sub