Simplifier un code vba excel

cedill23

XLDnaute Nouveau
Bonjour

Code:
 With Sheets("Feuil1")
        .[B2] = TextBox1.Value
        .[B3] = TextBox2.Value
        .[B4] = TextBox3.Value
        .[B5] = TextBox4.Value
        .[B6] = TextBox5.Value
         
    End With

Code:
UserForm1.CheckBox1.Value = Sheets("Feuil1").Range("C2").Value
UserForm1.CheckBox2.Value = Sheets("Feuil1").Range("C3").Value
UserForm1.CheckBox3.Value = Sheets("Feuil1").Range("C4").Value
UserForm1.CheckBox4.Value = Sheets("Feuil1").Range("C5").Value
UserForm1.CheckBox5.Value = Sheets("Feuil1").Range("C6").Value

y'a t'il un moyen d'ecrire ce code en boucle ? car j'ai comme 100 textbox et checkbox donc ça me ferai beaucoup de lignes ce qui est pas propre selon moi.

Merci
 
G

Guest

Guest
Re : Simplifier un code vba excel

Bonjour

Code:
Dim Ligne as long
 
For Ligne = 2 to 6
    UserForm1.Controls("CheckBox" & i -1)= Sheets("Feuil1").Range("C" & i)
Next
Je te laisse imaginer pour le reste.

A+
 

Membres actuellement en ligne

Aucun membre en ligne actuellement.

Statistiques des forums

Discussions
312 611
Messages
2 090 226
Membres
104 452
dernier inscrit
hamzamounir