|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- PathG = ThisWorkbook.Path & "\合同生成" '//结果文件夹
- Set FSO = CreateObject("Scripting.FileSystemObject")
- If FSO.FolderExists(PathG) = True Then
- FSO.GetFolder(PathG).Delete '//删除文件夹
- End If
- MkDir PathG '//创建文件夹
- Set SHX = Worksheets("合同信息")
- PATHM = ThisWorkbook.Path & "\模板.XLSX" '//外部模板
- Rem 模板中放置数据的单元格位置,和查询标题对应
- BRX = Split("C8,L8,L9", ",")
- CRX = Split("5,1,3", ",")
- BRX2 = Split("C12,L12", ",")
- CRX2 = Split("6,7", ",")
- LASTROW = SHX.Range("A65536").End(3).Row
- For IROW = 2 To LASTROW '//循环每一个值
- Rem 提示信息,在状态栏显示
- Application.StatusBar = "需拆分总数:" & LASTROW - 1 & " 个,当前是第:" & IROW - 1 & " 个,当前身份证号码是:" & SHX.Cells(IROW, 1).Value
- DoEvents
- Set WB = Workbooks.Open(PATHM) '//Workbooks.add
- Set SHW = WB.Worksheets("合同付款进度表")
- For X = 0 To UBound(BRX)
- SHW.Range(BRX(X)).Value = SHX.Cells(IROW, Val(CRX(X))).Value
- Next
- Set SHW = WB.Worksheets("付款申请单(打印)")
- For X = 0 To UBound(BRX2)
- SHW.Range(BRX2(X)).Value = SHX.Cells(IROW, Val(CRX2(X))).Value
- Next
- WB.SaveAs Filename:=PathG & "" & SHX.Cells(IROW, 1).Value & ".XLSX", FileFormat:=xlWorkbookDefault '//保存格式:xls =xlExcel8
- WB.Close True
- Next
复制代码 |
|