Option Explicit
Sub 按模板填充()
Dim arr(), i%, j%, iRowsPerPageA4%, rngFrame As Range
Dim shtResult As Worksheet
arr = ThisWorkbook.Worksheets("基础表").Range("A1").CurrentRegion.Value2
'Set shtResult = ThisWorkbook.Worksheets("结果表")
ThisWorkbook.Worksheets("模板").Copy after:=ThisWorkbook.Sheets(3)
Set shtResult =
网页链接 '结果表用新生成的,免得冲掉了旧表(毕竟没有原文件,不知道具体情况)
ThisWorkbook.Worksheets("模板").
网页链接 shtResult.Range("A1") '模板复制到结果表,这个是为了列宽也复制过来
iRowsPerPageA4 = 35 '我这例子是A4纸每页35行
Set rngFrame = ThisWorkbook.Worksheets("模板").Rows("1:" & iRowsPerPageA4) '空框架行,即模板行
With shtResult
.Name = "结果表by随风"
For i = 2 To UBound(arr)
网页链接 .Cells(iRowsPerPageA4 * (i - 2) + 1, 1) '框架
.Cells(iRowsPerPageA4 * (i - 2) + 3, 2).Value = arr(i, 1) '帐号
.Cells(iRowsPerPageA4 * (i - 2) + 4, 2).Value = arr(i, 2) '户名
Next i
End With
End Sub