Create multiple files based on list in Excel

DariuszSokol

New Member
Joined
Oct 10, 2020
Messages
1
Office Version
  1. 365
  2. 2013
Platform
  1. 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

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
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,214,914
Messages
6,122,211
Members
449,074
Latest member
cancansova

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top