I'm a complete beginner in VBA.
I created several checkboxes in excel (not active X) and I would like to do particular kind of control: I have checkboxes named A, B, C and D I would like to do one (or more) VBA macro that would do : If B is checked/unchecked then C and D are checked/unchecked If A is checked/unchecked then B,C and D are checked/unchecked
I tried the following for the whole control :
Sub BoucleCheckBoxes_Formulaire()
Dim Cb As CheckBox
'Boucle sur les checkboxes formulaires de la Feuil1
For Each Cb In ActiveSheet.CheckBoxes
'si la case est cochée
'(utilisez xlOff pour vérifier le statut "décoché")
If Cb.Value = xlOn Then
Cb.Value = xlOff
Else
If Cb.Value = xlOff Then
Cb.Value = xlOn
End If
End If
Next Cb
End Sub
But I have a problem: The checkbox linked to the macro is always checked (though on each click the other checkboxes state toggle as expected), probably because it's included in the loop as the other checkboxes. In fact I would like to be able to apply the checkbox state to a determined and limited list of other checkboxes
I couldn't find if it is possible to select a group of checkboxes depending on their position or name
can anyone help, please
thank you
Aucun commentaire:
Enregistrer un commentaire