Bonjour,

J'ai un tableau sur un userform composé de textbox. Pour mon projet, je dois transférer les données du userform vers un tableau de récap excel... Mais je bloque sur mon code car il y a trop de répétition et je ne sais pas comment enchainer les actions. Voici mon code:

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
22
23
24
DerLig = Sheets("Jour P1").Cells(Sheets("Jour P1").Columns(1).Cells.Count, 1).End(xlUp).Row + 1  'Récupère la dernière ligne, +1 pour ligne où écrire
Sheets("Jour P1").Cells(DerLig, 1) = EnrgJour.TBDatejour
Sheets("Jour P1").Cells(DerLig, 2) = Format(EnrgJour.TBheurejour1, "hh:mm")
Sheets("Jour P1").Cells(DerLig, 3) = "Prélèvement 1"
Sheets("Jour P1").Cells(DerLig, 4) = Format(EnrgJour.TBJour1L1, "0") 'chaque TB correspond à une textbox L1= ligne1
Sheets("Jour P1").Cells(DerLig, 5) = Format(EnrgJour.TBJour2L1, "0")
Sheets("Jour P1").Cells(DerLig, 6) = Format(EnrgJour.TBJour3L1, "0")
Sheets("Jour P1").Cells(DerLig, 7) = Format(EnrgJour.TBJour4L1, "0")
Sheets("Jour P1").Cells(DerLig, 8) = Format(EnrgJour.TBJour5L1, "0")
Sheets("Jour P1").Cells(DerLig, 9) = Format(EnrgJour.TBJour6L1, "0")
Sheets("Jour P1").Cells(DerLig, 10) = Format(EnrgJour.TBJour7L1, "0")
 
???????????????????????????????????????????????????????????????????
 
Sheets("Jour P1").Cells(DerLig, 1) = EnrgJour.TBDatejour
Sheets("Jour P1").Cells(DerLig, 2) = Format(EnrgJour.TBheurejour2, "hh:mm")
Sheets("Jour P1").Cells(DerLig, 3) = "Prélèvement 2"
Sheets("Jour P1").Cells(DerLig, 4) = Format(EnrgJour.TBJour1L2, "0")
Sheets("Jour P1").Cells(DerLig, 5) = Format(EnrgJour.TBjour2L2, "0")
Sheets("Jour P1").Cells(DerLig, 6) = Format(EnrgJour.TBJour3L2, "0")
Sheets("Jour P1").Cells(DerLig, 7) = Format(EnrgJour.TBJour4L2, "0")
Sheets("Jour P1").Cells(DerLig, 8) = Format(EnrgJour.TBJour5L2, "0")
Sheets("Jour P1").Cells(DerLig, 9) = Format(EnrgJour.TBJour6L2, "0")
Sheets("Jour P1").Cells(DerLig, 10) = Format(EnrgJour.TBJour7L2, "0")
J'ai mis des points d'interrogations la ou il devrait y avoir un truc voulant dire "ensuite" ou "après".... Si c'est possible...
Ce style de code doit etre répéter pour chaque ligne de mon tableau de départ. Chaque ligne correspond à un "prélèvement" qui doit etre mentionner dans le tableau de récap...
C'est pas facile quand on est nul...
Merci à vous pour votre aide.