' contrôle formulaire
Sub decoche()
Dim Ctl As Shape
For Each Ctl In ActiveSheet.Shapes
If Left(Ctl.Name, 9) = "Check Box" Then Ctl.ControlFormat.Value = xlOff
Next Ctl
End Sub
Sub coche()
Dim Ctl As Shape
For Each Ctl In ActiveSheet.Shapes
If Left(Ctl.Name, 9) = "Check Box" Then Ctl.ControlFormat.Value = xlOn
Next Ctl
End Sub
' contrôle activeX
Sub decocheX()
Dim Ctl As OLEObject
For Each Ctl In ActiveSheet.OLEObjects
If TypeOf Ctl.Object Is MSForms.CheckBox Then Ctl.Object = False
Next Ctl
End Sub
Sub cocheX()
Dim Ctl As OLEObject
For Each Ctl In ActiveSheet.OLEObjects
If TypeOf Ctl.Object Is MSForms.CheckBox Then Ctl.Object = True
Next Ctl
End Sub
Bonjour à tous
Code:' contrôle formulaire Sub decoche() Dim Ctl As Shape For Each Ctl In ActiveSheet.Shapes If Left(Ctl.Name, 9) = "Check Box" Then Ctl.ControlFormat.Value = xlOff Next Ctl End Sub Sub coche() Dim Ctl As Shape For Each Ctl In ActiveSheet.Shapes If Left(Ctl.Name, 9) = "Check Box" Then Ctl.ControlFormat.Value = xlOn Next Ctl End Sub ' contrôle activeX Sub decocheX() Dim Ctl As OLEObject For Each Ctl In ActiveSheet.OLEObjects If TypeOf Ctl.Object Is MSForms.CheckBox Then Ctl.Object = False Next Ctl End Sub Sub cocheX() Dim Ctl As OLEObject For Each Ctl In ActiveSheet.OLEObjects If TypeOf Ctl.Object Is MSForms.CheckBox Then Ctl.Object = True Next Ctl End Sub
Sub test_I()
'coche tous les types de CheckBox
Application.ScreenUpdating = False
Cochez True
End Sub
Sub test_II()
'décoche tous les types de CheckBox
Application.ScreenUpdating = False
Cochez False
End Sub
Private Sub Cochez(statut As Boolean)
Dim c As Object
With ActiveSheet
.CheckBoxes.Value = statut
For Each c In .OLEObjects
If TypeName(c.Object) = "CheckBox" Then c.Object.Value = statut
Next c
End With
End Sub