|
修改了您的代碼:
- Sub test()
- Application.DisplayAlerts = False
- Dim d As Object, p$, f
- p = ThisWorkbook.Path
- Set d = CreateObject("scripting.dictionary")
- f = Dir(p & "" & "*.xls")
- Do While f <> ""
- If InStrRev(f, "-") Then
- f = Mid(f, 1, InStrRev(f, "-"))
- d(f) = d(f) + 1
- End If
- f = Dir
- Loop
- 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)
- d(f) = d(f) + 1
- .Cells(8, "c") = ThisWorkbook.Sheets(1).Cells(i, 4) '黍J/R NO.
- .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 ThisWorkbook.Path & "" & ThisWorkbook.Sheets(1).Cells(i, 1) & Format(d(f), "00") & ".xls"
- Next
- template.Close False
- Application.DisplayAlerts = False
- End Sub
复制代码 |
|