cellules avec condition relié avec checkbox
Bonjour,
Je suis débutant en vba. Voici mon problème. Je veux quand je remplir les cellules a1,a2 et a3 et que si les conditions sont vrai que le checkbox3 se coche automatiquement. Si les conditions sont fausses que le checkbox4 se coche. merci
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| Sub Macro1()
'
' Macro1 Macro
cond1 = Range("a1") <= 10
cond2 = Range("a2") <= 10
cond3 = Range("a3") >= 10
If cond1 And cond2 And cond3 = True Then
CheckBox3.Value = True
CheckBox4.Value = False
End If
If cond1 And cond2 = True And cond3 = False Then
CheckBox3.Value = false
CheckBox4.Value = True
End If
If cond1 And cond3 = True And cond2 = False Then
CheckBox3.Value = false
CheckBox4.Value = True
End If
If cond1 = True And cond2 And cond3 = False Then
CheckBox3.Value = false
CheckBox4.Value = True
End If
If cond1 And cond2 And cond3 = False Then
CheckBox3.Value = false
CheckBox4.Value = True
End If
If cond1 And cond2 = False And cond3 = True Then
CheckBox3.Value = False
CheckBox4.Value = True
End If
If cond1 And cond3 = False And cond2 = True Then
CheckBox3.Value = False
CheckBox4.Value = True
End If
If cond1 = False And cond2 And cond3 = True Then
CheckBox3.Value = False
CheckBox4.Value = True
End If
End Sub
Private Sub Worksheet_change(ByVal taget As Excel.Range)
If Range("a1") Or Range("a2") Or Range("a3") <> 0 Then
Run Macro1
End If
If Range("a1") Or Range("a2") Or Range("a3") = 0 Then
Run Macro1
End If
End Sub |