|
Sub test()
Application.DisplayAlerts = False
Dim d As Object, p$, f
Dim cFile$
p = ThisWorkbook.Path
Set d = CreateObject("scripting.dictionary")
Set template = Workbooks.Open(p & "\" & "MODEL.xls")
For i = 2 To ThisWorkbook.Sheets(1).[d65536].End(xlUp).Row
With template.Sheets("statements")
f = ThisWorkbook.Sheets(1).Cells(i, 1)
Do
d(f) = d(f) + 1
cFile = ThisWorkbook.Path & "\" & f & Format(d(f), "00") & ".xls"
If Dir(cFile) = "" Then Exit Do
Loop
.Cells(8, "c") = ThisWorkbook.Sheets(1).Cells(i, 4)
.Cells(8, "e") = ThisWorkbook.Sheets(1).Cells(i, 5)
.Cells(8, "f") = ThisWorkbook.Sheets(1).Cells(i, 14)
.Cells(8, "g") = ThisWorkbook.Sheets(1).Cells(i, 15)
End With
template.SaveCopyAs cFile
Next
template.Close False
Application.DisplayAlerts = False
End Sub
|
|