|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 批量导出到模板()
Dim ar, br(), cr, i%, j%, wb1 As Workbook, wb2 As Workbook, wb As Workbook, a%
Set wb1 = ThisWorkbook
a = wb1.Sheets("04专业").Range("e2").End(xlDown).Row
ar = wb1.Sheets("04专业").Range("b2:e" & a)
Set wb2 = Workbooks.Open(wb1.Path & "\模板.xlsx")
For i = 1 To UBound(ar)
Set wb = Workbooks.Add
wb1.Sheets.Copy before:=wb.Sheets(Sheets.Count)
wb2.Sheets(1).UsedRange.Copy wb.Sheets(Sheets.Count).Range("a1")
With wb.Sheets(Sheets.Count)
.Name = ar(i, 2)
For j = 1 To 4
.Cells(4, j).Value = ar(i, j)
Next j
End With
wb.SaveAs (wb1.Path & "\" & ar(i, 2) & ".xlsx")
wb.Close
Next i
wb2.Close 0
MsgBox "导出完毕!"
End Sub |
评分
-
1
查看全部评分
-
|