Bonsoir,
je voudrais savoir s'il est possible d'incrémenter une textbox. Je m'explique
j'ai 75 textbox dans lesquelles je charge des données depuis une feuille excel
de la façon suivante :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Private Sub premiermois()
TextBox1 = Range("A3")
TextBox2 = Range("B3"): TextBox2.Value = Format(TextBox2.Value, "hh:mm")
TextBox3 = Range("C3"): TextBox3.Value = Format(TextBox3.Value, "hh:mm")
TextBox4 = Range("A4")
TextBox5 = Range("B4"): TextBox5.Value = Format(TextBox5.Value, "hh:mm")
TextBox6 = Range("C4"): TextBox6.Value = Format(TextBox6.Value, "hh:mm")
TextBox7 = Range("A5")
TextBox8 = Range("B5"): TextBox8.Value = Format(TextBox8.Value, "hh:mm")
TextBox9 = Range("C5"): TextBox9.Value = Format(TextBox9.Value, "hh:mm")
TextBox10 = Range("A6")
TextBox11 = Range("B6"): TextBox11.Value = Format(TextBox11.Value, "hh:mm")
TextBox12 = Range("C6"): TextBox12.Value = Format(TextBox12.Value, "hh:mm")
TextBox13 = Range("A7")
TextBox14 = Range("B7"): TextBox14.Value = Format(TextBox14.Value, "hh:mm")
TextBox15 = Range("C7"): TextBox15.Value = Format(TextBox15.Value, "hh:mm")
TextBox16 = Range("A8")
TextBox17 = Range("B8"): TextBox17.Value = Format(TextBox17.Value, "hh:mm")
TextBox18 = Range("C8"): TextBox18.Value = Format(TextBox18.Value, "hh:mm")
' etc....
End Sub
est-il possible de faire une boucle?

et avec ça? :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
Private Sub moispremier()
Range("B57") = TextBox2
Range("C57") = TextBox3
Range("B58") = TextBox5
Range("C58") = TextBox6
Range("B59") = TextBox8
Range("C59") = TextBox9
Range("B60") = TextBox11
Range("C60") = TextBox12
Range("B61") = TextBox14
Range("C61") = TextBox15
' etc....
End Sub
et encore avec ça :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
cible = TextBox2
cible.Offset(0, 1) = TextBox3
cible.Offset(1, 0) = TextBox5
cible.Offset(1, 1) = TextBox6
cible.Offset(2, 0) = TextBox8
cible.Offset(2, 1) = TextBox9
cible.Offset(3, 0) = TextBox11
cible.Offset(3, 1) = TextBox12
cible.Offset(4, 0) = TextBox14
cible.Offset(4, 1) = TextBox15
' etc...
End Sub
Je sais faire les boucles avec un compteur, comme ça :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
Private Sub OK_click()
'Choix de la page ou trouver les éléments pour remplir mon formulaire
Dim ssenfant As String
ssenfant = enfant
ActiveWorkbook.Sheets(ssenfant).Activate
'chargement de la liste des mois (ligne,colonne)
Dim counter As Long
For counter = 1 To 49 Step 4
ListBox2.AddItem ActiveWorkbook.Sheets(ssenfant).Cells(1, counter)
Next
End Sub
J'ai essayé do loop, do while, mais ce qui me pose pb c'est qu'il y ait deux choses à incrémenter et surtout les textbox, apparemment on ne peut pas mettre textbox(x) pour incrémenter le x
Si vous avez des idées, cela me permettrait de raccourcir mon code.
Merci d'avance
Titemireille