Добрый день, подскажите, пожалуйста где ошибка:
На форме 10 CheckBox'ов , при выборе каждого из них выполняется определенное условие,проблема, в том, что если не выбрать первый CheckBox для выполнения, то следующие никакие не работают(при их выборе , не выполняется условия).
Пример:
Private Sub CommandButton2_Click()
If Not IsDate(TextBox1) Then MsgBox "Не дата", vbCritical, "Ошибка": Exit Sub
If Not IsDate(TextBox2) Then MsgBox "Не дата", vbCritical, "Ошибка": Exit Sub
If CheckBox1 = True Then
Dim lLastRow As Long, li As Long, lCountSv As Long, lCountSp As Long, lCountT As Long, lCountTP As Long
With Sheets("Лист1")
lLastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
For li = 2 To lLastRow
If .Cells(li, 1) <> "" Then
If CDate(.Cells(li, 1)) >= CDate(TextBox1) And CDate(.Cells(li, 1)) <= CDate(TextBox2) And .Cells(li, 4) = "AAA" And .Cells(li, 6) = "BBB" Then _
lCountSv = lCountSv + 1
If CDate(.Cells(li, 1)) >= CDate(TextBox1) And CDate(.Cells(li, 1)) <= CDate(TextBox2) And .Cells(li, 4) = "AAA" And .Cells(li, 6) = "CCC" Then _
lCountT = lCountT + 1
End If
End If
Next li
End With
If CheckBox2 = True Then
Dim lLastRow2 As Long, ki As Long, lCountSv2 As Long, lCountSp2 As Long, lCountT2 As Long, lCountTp2 As Long
With Sheets("Âûäà÷à")
lLastRow2 = .Cells(.Rows.Count, 1).End(xlUp).Row
For ki = 2 To lLastRow
If .Cells(ki, 1) <> "" Then
If CDate(.Cells(ki, 1)) >= CDate(TextBox1) And CDate(.Cells(ki, 1)) <= CDate(TextBox2) And .Cells(ki, 4) = "111" And .Cells(ki, 6) = "222" Then _
lCountSv2 = lCountSv2 + 1
If CDate(.Cells(ki, 1)) >= CDate(TextBox1) And CDate(.Cells(ki, 1)) <= CDate(TextBox2) And .Cells(ki, 4) = "111" And .Cells(ki, 6) = "333" Then _
lCountT2 = lCountT2 + 1
End If
End If
Next ki
End With
и т.д.