Selection de plusieurs Labels et boutons

Bonjour,

Je souhaite en fonction de la sélection d'une checkbox "activer" ou "désactiver" plusieurs label et option button.

J'ai écris un code qui fonctionne très bien :

If checkbox1 = true then

Label38.Enabled = False

Label39.Enabled = False

Label40.Enabled = False

Label41.Enabled = False

Label42.Enabled = False

Label43.Enabled = False

Label44.Enabled = False

OptionButton78.Enabled = False

OptionButton79.Enabled = False

OptionButton80.Enabled = False

OptionButton81.Enabled = False

OptionButton82.Enabled = False

OptionButton83.Enabled = False

OptionButton84.Enabled = False

OptionButton85.Enabled = False

OptionButton86.Enabled = False

OptionButton87.Enabled = False

OptionButton88.Enabled = False

OptionButton89.Enabled = False

OptionButton90.Enabled = False

OptionButton91.Enabled = False

OptionButton92.Enabled = False

OptionButton93.Enabled = False

OptionButton94.Enabled = False

OptionButton95.Enabled = False

OptionButton96.Enabled = False

OptionButton97.Enabled = False

OptionButton98.Enabled = False

End if

ma question est la suivante, peut-on écrire quelque chose de plus simple du style (sans avoir à reprendre tous les numéros de boutons et de label un par un) :

If checkbox1 = true then

Label38 to Label44.Enabled = False

OptionButton78 to OptionButton98.Enabled = False

end if

??

Merci

bonjour,

Si on opère dans une Userform, on peut utiliser ce code :

For i = 38 To 44
       Me("Label" & i).Enabled = False
Next i

à adapter pour les Optionbuttons

A+

Je suis bien dans un Userform.

Ce code fonctionne, mais je ne sais pas pourquoi... de façon aléatoire.

Un coup il fonctionne, un coup il bug.

J'ai essayé à remplacer le "Me" par "Userform"... idem.

J'ai trouvé mon erreur... il me manquait un N° au milieu...

Merci !

Rechercher des sujets similaires à "selection labels boutons"