|
Sub 按钮15_单击()
Dim arr
Dim i%
Sheet2.Select '数据表
arr = Range(Cells(2, 1), Cells(65536, 5)) '数据区域
Sheet1.Select '打印表
A = Cells(1, 13) '起始页M1
b = Cells(2, 13) '终止页M2
For i = A To b '设定打印起止页
Sheets("sheet1").Unprotect Password:=123 '解除保护
Cells(3, 10) = arr(i, 2)
Cells(4, 2) = arr(i, 1)
Cells(4, 6) = arr(i, 3)
Cells(5, 3) = arr(i, 4)
Cells(5, 9) = arr(i, 5)
ActiveSheet.PageSetup.PrintArea = "$A$1:$J$24" '设定打印区域
Sheets("Sheet1").PrintOut Copies:=1 '进行打印
Cells(3, 13) = Format(Cells(3, 13) + 1, "000000") '编码
Cells(6, 3) = "NO:YJ" & Cells(3, 13) '编码
Sheets("sheet1").Protect Password:=123 '增加保护
Next
End Sub |
|