Я пытаюсь использовать флажок ActiveX, чтобы отфильтровать, какие строки кода будут выполняться, но появляется ошибка «400», также по какой-то причине я не могу снять эти флажки, кто-то может помочь, пожалуйста?
.
.
.
If CheckBox1.Value = True Then
Columns("A:F").AutoFilter Field:=1, Criteria1:=">11999", Operator:=xlAnd, Criteria2:="<13000"
ActiveSheet.PrintOut
End If
If CheckBox2.Value = True Then
Columns("A:F").AutoFilter Field:=1, Criteria1:=">12999", Operator:=xlAnd, Criteria2:="<14000"
ActiveSheet.PrintOut
End If
.
.
.
РЕДАКТИРОВАТЬ (весь код - будет гораздо больше одинаковых условий только с другим флажком и другим диапазоном):
Sub TISK_IV_OC()
Sheets("TISK IV OC").Activate
Dim ws As Worksheet
Set ws = ActiveSheet
If ws.Range("A1") = "" Then
MsgBox ("Neni co tisknout › nejdrive preved data!")
Exit Sub
End If
Sheets("TISK IV OC").PageSetup.CenterFooter = "&""Calibri,Bold""&18 " & "IV OC: " & Format(Date + 1, "dd.mm.yyyy")
Application.PrintCommunication = False
With Sheets("TISK IV OC").PageSetup
.FitToPagesWide = 1
.FitToPagesTall = False
End With
Application.PrintCommunication = True
Dim x As Integer
For x = 1 To 2
Sheets("TISK IV OC").PageSetup.CenterHeader = "&""Calibri,Bold""&18 " & x & " . KOLO"
If ws.CheckBox1.Value = True Then
Debug.Print ws.CheckBox1.Value
ws.Columns("A:F").AutoFilter Field:=1, Criteria1:=">11999", Operator:=xlAnd, Criteria2:="<13000"
ws.PrintOut
End If
If ws.CheckBox2.Value = True Then
Debug.Print ws.CheckBox1.Value
ws.Columns("A:F").AutoFilter Field:=1, Criteria1:=">12999", Operator:=xlAnd, Criteria2:="<14000"
ws.PrintOut
End If
Next x
ActiveSheet.ShowAllData
ws.Range("A1").Select
End Sub
Private Sub CheckBox1_Click()
End Sub