|
Private Sub 打印单据_Click()
Dim a As String ' 声明变量a,用于存储字符串
If Cells(5, 20).Value > Cells(5, 21).Value Then MsgBox ("初始页必须小于结束页!"): Exit Sub
For i = Cells(5, 20).Value To Cells(5, 21).Value Step 17 '起始序号到结束序号
[Q2].Resize(10000, 1) = "" '
m = 1
For j = i To i + 16
If j <= Cells(5, 21).Value Then
m = m + 1
Cells(m, 17) = j
End If
Next j
Rows("2:18").EntireRow.Hidden = False ' 取消隐藏选中的行
a = Cells(Rows.Count, 17).End(xlUp).Row
Rows(a + 1 & ":18").EntireRow.Hidden = True ' 隐藏选中的行
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False ' 打印当前页
Next i
End Sub
|
|