Private Sub CommandButton1_Click() Application.ScreenUpdating = False Sheet3.Visible = True Sheet3.[A2:H27].ClearContents lstr = Sheet1.[a65536].End(xlUp).Row For i = 2 To lstr rr = Application.Match(Sheet1.Cells(i, 1), Sheet4.Columns(1), 0) If Sheet4.Cells(rr, 3) = "是" Then For j = 1 To 8 Sheet3.Cells(2 + m, j) = Sheet1.Cells(i, j) Next If Sheet1.Cells(i, 1) = Sheet1.Cells(i + 1, 1) Then m = m + 1 Else m = 0 Sheet3.[A28] = Sheet3.Cells(2, 1) & " 合计" Sheet3.PrintOut Sheet3.[A2:H27].ClearContents Sheet3.[A28].ClearContents End If End If Next If Application.CountIf(Sheet4.Columns(3), "是") = 0 Then MsgBox "错误提示: 你尚未在表格打印参数设置中选中想要打印的表格!" Sheet4.Visible = True Sheet4.Activate End If Sheet3.Visible = False Application.ScreenUpdating = True End Sub Private Sub CommandButton3_Click() Application.ScreenUpdating = False Sheet4.Visible = True Sheet4.Activate msg = "本次操作将进入打印参数设置表格,请选择你是否想清空设置表中已经设置好的参数: " & Chr(10) & Chr(10) & Chr(10) & "1.如果你想清空以前已经设置好的参数,重新进行设置,请按""确定""" & _ Chr(10) & Chr(10) & "2.如果你想保留以前的设置,仅仅想对其中部分参数进行修改,请按""取消""" & Chr(10) & Chr(10) & Chr(10) & _ "建议: 如果不是" & Sheet1.Name & "表中数据发生变动,请按""取消"",进入设置表中直接修改参数,以免再重新设置所有的参数,重复劳动." If MsgBox(msg, 1) = 1 Then
Sheet4.[A4:C65536].Clear lstr = Sheet1.[a65536].End(xlUp).Row For i = 2 To lstr If Sheet1.Cells(i, 1) <> Sheet1.Cells(i - 1, 1) Then Sheet4.Cells(4 + m, 1) = Sheet1.Cells(i, 1) Sheet4.Cells(4 + m, 2) = Sheet1.Cells(i, 2) Sheet4.Cells(4 + m, 3).Select With Selection.Validation .Add Type:=xlValidateList, Formula1:="是" End With m = m + 1 End If Next End If
Application.ScreenUpdating = True End Sub
Private Sub Worksheet_Activate() Sheet3.Visible = False Sheet4.Visible = False End Sub 請幫解釋,謝謝
|