Rize S. answered 03/23/23
Senior IT Certified Trainer, IT Developer & DBA Administrator
To insert the name from the list into the copied workbook template, you can use the following code:
Sub copy_workbook()
Dim name_list As Range
Dim name_cell As Range
Dim template_book As Workbook
Dim new_book As Workbook
Set name_list = Range("A2:A" & Range("A2").End(xlDown).Row) 'Assuming names start at A2
Set template_book = Workbooks.Open("C:\template.xlsx") 'Change the path to your template workbook
For Each name_cell In name_list
Set new_book = Workbooks.Add(template_book.FullName)
new_book.SaveAs "C:\" & name_cell.Value & ".xlsx" 'Change the path to your desired folder
new_book.Worksheets("Sheet1").Range("A1").Value = name_cell.Value 'Change "Sheet1" to the name of your desired worksheet
new_book.Close SaveChanges:=True
Next name_cell
template_book.Close SaveChanges:=False
End Sub
In this code, we are adding a line that sets the value of cell A1 in the new workbook to the name in the corresponding cell in the name list. This line is:
new_book.Worksheets("Sheet1").Range("A1").Value = name_cell.Value
Make sure to change "Sheet1" to the name of your desired worksheet where you want to insert the name.