ahmedmohamedkamal
New Member
- Joined
- Dec 28, 2019
- Messages
- 7
- Office Version
- 2016
- Platform
- Windows
Hi every one
I have a code edited from old thread that create new excel files based on template and named after specified range in the master sheet
i have a problem that it copy the first cell A1 in every C6 for all generated files
i need A1 copied to C6 1st file and A2 copied to C6 2nd file ...........etc also i need to make the range dynamic according to used cells no just from a1 to a8
The code is
I have a code edited from old thread that create new excel files based on template and named after specified range in the master sheet
i have a problem that it copy the first cell A1 in every C6 for all generated files
i need A1 copied to C6 1st file and A2 copied to C6 2nd file ...........etc also i need to make the range dynamic according to used cells no just from a1 to a8
The code is
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("Sheet1").Range("A1:A8").Values
Set wkbTemplate = Application.Workbooks.Open(strTemplatePath)
For Each rng In rngNames.Cells
wkbTemplate.Worksheets("Sheet1").Range("C6").Value = ThisWorkbook.Worksheets("Sheet1").Range("A1:A8").Value
wkbTemplate.SaveAs strSavePath & rng.Value
Next rng
wkbTemplate.Close SaveChanges:=False
End Sub
Last edited by a moderator: