I tried to use code from this thread:
But I have problem with adding new details in "template" using nested "For Each". I tried to ask there:
but I saw that is recommended to start new thread (because it is from 2013), and I will copy my question from there:
JLGWhiz said:
Try it this way.
Code:
Sub create()
Dim wb As Workbook, sh1 As Worksheet, lr As Long, rng As Range
Set sh1 = Sheets("Index") 'Edit sheet name
Set sh2 = Sheets("Data") 'Edit sheet name
lr = sh1.Cells(Rows.Count, "Q").End(xlUp).Row
Set rng = sh1.Range("Q16:Q" & lr)
For Each c In rng
Sheets("Template").Copy 'Edit sheet name
Set wb = ActiveWorkbook
wb.Sheets(1).Range("D10") = c.Value
sh2.Copy After:=wb.Sheets(1)
wb.SaveAs c.Value & ".xlsx"
wb.Close False
Next
End Sub
I know that is very old thread, but it is a very useful for me, and thank you for that. I have additional question: I have to import additional cell from sheet "data" (for example from column R of the same row) in some other place of sheet "template" (for example in E6 cell). When I try to do this in the same way as you add cells from column Q of sheet "data" to sheet D10 cell in "template", I succeed but I always get cell from the last row, and I need it from the same row. Can you, please, help me?
VBA help required: Creating multiple workbooks from a template and a list of names
Hopefully someone smarter than me can provide me with a neat VBA macro that will do the following; The easiest way I can describe the scenario I am trying to create, is to use a company list of personnel (my index) and to generate a time-sheet workbook per person based on a pre-populated...
www.mrexcel.com
But I have problem with adding new details in "template" using nested "For Each". I tried to ask there:
VBA help required: Creating multiple workbooks from a template and a list of names
Hopefully someone smarter than me can provide me with a neat VBA macro that will do the following; The easiest way I can describe the scenario I am trying to create, is to use a company list of personnel (my index) and to generate a time-sheet workbook per person based on a pre-populated...
www.mrexcel.com
but I saw that is recommended to start new thread (because it is from 2013), and I will copy my question from there:
JLGWhiz said:
Try it this way.
Code:
Sub create()
Dim wb As Workbook, sh1 As Worksheet, lr As Long, rng As Range
Set sh1 = Sheets("Index") 'Edit sheet name
Set sh2 = Sheets("Data") 'Edit sheet name
lr = sh1.Cells(Rows.Count, "Q").End(xlUp).Row
Set rng = sh1.Range("Q16:Q" & lr)
For Each c In rng
Sheets("Template").Copy 'Edit sheet name
Set wb = ActiveWorkbook
wb.Sheets(1).Range("D10") = c.Value
sh2.Copy After:=wb.Sheets(1)
wb.SaveAs c.Value & ".xlsx"
wb.Close False
Next
End Sub
I know that is very old thread, but it is a very useful for me, and thank you for that. I have additional question: I have to import additional cell from sheet "data" (for example from column R of the same row) in some other place of sheet "template" (for example in E6 cell). When I try to do this in the same way as you add cells from column Q of sheet "data" to sheet D10 cell in "template", I succeed but I always get cell from the last row, and I need it from the same row. Can you, please, help me?