DariuszSokol
New Member
- Joined
- Oct 10, 2020
- Messages
- 1
- Office Version
- 365
- 2013
- Platform
- Windows
Hi,
I would like to ask for some support in fixing the VBA-code.
Main idea of this code is to grab the template file and save it multiple time under names from the list.
In the same list is several other parameters (same row, other cell) which has to be added into each file.
1. I cannot put other parameters into each file - vba just put whole time same data (from last row)
2. I want to use file name taken from the list cell
I would like to ask for some support in fixing the VBA-code.
Main idea of this code is to grab the template file and save it multiple time under names from the list.
In the same list is several other parameters (same row, other cell) which has to be added into each file.
1. I cannot put other parameters into each file - vba just put whole time same data (from last row)
2. I want to use file name taken from the list cell
VBA Code:
Public Sub SaveTemplate()
Const strSavePath As String = "c:\VBA\"
Const strTemplatePath As String = "c:\VBA\template.xlsm"
Dim rngNames As Range
Dim rngC As Range
Dim rng As Range
Dim wkbTemplate As Workbook
With ThisWorkbook.Worksheets("Template")
Set rngNames = .Range("G2", .Range("G" & Rows.Count).End(xlUp))
Set rngC = .Range("H2", .Range("H" & Rows.Count).End(xlUp))
End With
Set wkbTemplate = Application.Workbooks.Open(strTemplatePath)
For Each rng In rngNames.Cells
With wkbTemplate.Worksheets("Customer Project")
.Range("A13").Value = rng.Value
.Range("J13").Resize(rngC.Count).Value = rngC.Value
End With
wkbTemplate.SaveAs strSavePath & rng.Value
Next rng
wkbTemplate.Close SaveChanges:=False
End Sub