|
本帖最后由 zjdh 于 2017-4-26 18:57 编辑
Private Sub CommandButton1_Click()
Dim I%, C$, B, W%
B = Array("表一", "表二", "附表一", "附表二")
For I = 1 To 4
If Controls("CheckBox" & I) = True Then C = C & B(I - 1) & ","
Next
If C = "" Then MsgBox "你没有勾选打印报表!": Exit Sub
If MsgBox("打印的表格为: " & Chr(10) & C & " 确定打印吗?", 4 + 32) = 7 Then Exit Sub
With Sheet1
For I = 30 To 11 Step -1
If .Cells(I, "G").Value <> "" Then
W = I
Exit For
End If
Next
If CheckBox1.Value = True Then
If CheckBox2.Value = True Then
.Range("B2:D14").PrintOut
Else
.Range("B2:D6").PrintOut
End If
Else
If CheckBox2.Value = True Then .Range("B10:D14").PrintOut
End If
If CheckBox3.Value = True Then
If CheckBox4.Value = True Then
.Range("F2:H" & W).PrintOut
Else
.Range("F2:H8").PrintOut
End If
Else
If CheckBox4.Value = True Then .Range("F10:H" & W).PrintOut
End If
End With
MsgBox "打印完毕!"
Unload Me
End Sub
|
|