Bonjour

Voilà, j'ai un code qui me permet de remplir des plannings. Il fonctionne mais je le trouve lent à l’exécution.

Je vais avoir 4 sortes de plannings différents à remplir (hebdomadaire, bimensuel, tri mensuel et mensuel) 'exemple çi dessous correspond au bimensuel

Les données qui changerons par semaine pour la conception sont le S(N°) de la fin

Le planning est conçu de tel manière :

Tout les jours de la semaine,
Heure d'arrivée le matin (M1)
Heure de départ le matin(M2)
Heure d'arrivée l'après midi (S1)
Heure de départ l'après midi (S2)
Numéro de semaine S(N°)

J1M1S1 = cela correspond pour moi à Jour1(Lundi); Matin1(heure d'arrivée le matin) Semaine1(Première semaine)

Si quelqu'un à une idée pour améliorer et accélérer ce code je suis preneur.

Merci d'avance.

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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
Private Sub Valider_PlanningBimensuel_Click()
Application.DisplayAlerts = False
'----------------------Matin SEMAINE 1----------------
 
If Planning.J1M1S1 = "" Then
ActiveCell.Value = ""
Else: ActiveCell.Value = CDate(Planning.J1M1S1)
End If
    If Planning.J2M1S1 = "" Then
    ActiveCell.Offset(1, 0) = ""
    Else: ActiveCell.Offset(1, 0) = CDate(Planning.J2M1S1)
    End If
        If Planning.J3M1S1 = "" Then
        ActiveCell.Offset(2, 0) = ""
        Else: ActiveCell.Offset(2, 0) = CDate(Planning.J3M1S1)
        End If
            If Planning.J4M1S1 = "" Then
            ActiveCell.Offset(3, 0) = ""
            Else: ActiveCell.Offset(3, 0) = CDate(Planning.J4M1S1)
            End If
                If Planning.J5M1S1 = "" Then
                ActiveCell.Offset(4, 0) = ""
                Else: ActiveCell.Offset(4, 0) = CDate(Planning.J5M1S1)
                End If
                    If Planning.J6M1S1 = "" Then
                    ActiveCell.Offset(5, 0) = ""
                    Else: ActiveCell.Offset(5, 0) = CDate(Planning.J6M1S1)
                    End If
                        If Planning.J7M1S1 = "" Then
                        ActiveCell.Offset(6, 0) = ""
                        Else: ActiveCell.Offset(6, 0) = CDate(Planning.J7M1S1)
                        End If
If Planning.J1M2S1 = "" Then
ActiveCell.Offset(0, 1) = ""
Else: ActiveCell.Offset(0, 1) = CDate(Planning.J1M2S1)
End If
    If Planning.J2M2S1 = "" Then
    ActiveCell.Offset(1, 1) = ""
    Else: ActiveCell.Offset(1, 1) = CDate(Planning.J2M2S1)
    End If
        If Planning.J3M2S1 = "" Then
        ActiveCell.Offset(2, 1) = ""
        Else: ActiveCell.Offset(2, 1) = CDate(Planning.J3M2S1)
        End If
            If Planning.J4M2S1 = "" Then
            ActiveCell.Offset(3, 1) = ""
            Else: ActiveCell.Offset(3, 1) = CDate(Planning.J4M2S1)
            End If
                If Planning.J5M2S1 = "" Then
                ActiveCell.Offset(4, 1) = ""
                Else: ActiveCell.Offset(4, 1) = CDate(Planning.J5M2S1)
                End If
                    If Planning.J6M2S1 = "" Then
                    ActiveCell.Offset(5, 1) = ""
                    Else: ActiveCell.Offset(5, 1) = CDate(Planning.J6M2S1)
                    End If
                        If Planning.J7M2S1 = "" Then
                        ActiveCell.Offset(6, 1) = ""
                        Else: ActiveCell.Offset(6, 1) = CDate(Planning.J7M2S1)
                        End If
 
'----------------------Soir SEMAINE 1----------------
If Planning.J1S1S1 = "" Then
ActiveCell.Offset(0, 2) = ""
Else: ActiveCell.Offset(0, 2) = CDate(Planning.J1S1S1)
End If
    If Planning.J2S1S1 = "" Then
    ActiveCell.Offset(1, 2) = ""
    Else: ActiveCell.Offset(1, 2) = CDate(Planning.J2S1S1)
    End If
        If Planning.J3S1S1 = "" Then
        ActiveCell.Offset(2, 2) = ""
        Else: ActiveCell.Offset(2, 2) = CDate(Planning.J3S1S1)
        End If
            If Planning.J4S1S1 = "" Then
            ActiveCell.Offset(3, 2) = ""
            Else: ActiveCell.Offset(3, 2) = CDate(Planning.J4S1S1)
            End If
                If Planning.J5S1S1 = "" Then
                ActiveCell.Offset(4, 2) = ""
                Else: ActiveCell.Offset(4, 2) = CDate(Planning.J5S1S1)
                End If
                    If Planning.J6S1S1 = "" Then
                    ActiveCell.Offset(5, 2) = ""
                    Else: ActiveCell.Offset(5, 2) = CDate(Planning.J6S1S1)
                    End If
                        If Planning.J7S1S1 = "" Then
                        ActiveCell.Offset(2, 2) = ""
                        Else: ActiveCell.Offset(6, 2) = CDate(Planning.J7S1S1)
                        End If
If Planning.J1S2S1 = "" Then
ActiveCell.Offset(0, 3) = ""
Else: ActiveCell.Offset(0, 3) = CDate(Planning.J1S2S1)
End If
    If Planning.J2S2S1 = "" Then
    ActiveCell.Offset(1, 3) = ""
    Else: ActiveCell.Offset(1, 3) = CDate(Planning.J2S2S1)
    End If
        If Planning.J3S2S1 = "" Then
        ActiveCell.Offset(2, 3) = ""
        Else: ActiveCell.Offset(2, 3) = CDate(Planning.J3S2S1)
        End If
            If Planning.J4S2S1 = "" Then
            ActiveCell.Offset(3, 3) = ""
            Else: ActiveCell.Offset(3, 3) = CDate(Planning.J4S2S1)
            End If
                If Planning.J5S2S1 = "" Then
                ActiveCell.Offset(4, 3) = ""
                Else: ActiveCell.Offset(4, 3) = CDate(Planning.J5S2S1)
                End If
                    If Planning.J6S2S1 = "" Then
                    ActiveCell.Offset(5, 3) = ""
                    Else: ActiveCell.Offset(5, 3) = CDate(Planning.J6S2S1)
                    End If
                        If Planning.J7S2S1 = "" Then
                        ActiveCell.Offset(6, 3) = ""
                        Else: ActiveCell.Offset(6, 3) = CDate(Planning.J7S2S1)
                        End If
'----------------------Matin SEMAINE 2----------------
 
If Planning.J1M1S2 = "" Then
ActiveCell.Offset(9, 0) = ""
Else: ActiveCell.Offset(9, 0) = CDate(Planning.J1M1S2)
End If
    If Planning.J2M1S2 = "" Then
    ActiveCell.Offset(10, 0) = ""
    Else: ActiveCell.Offset(10, 0) = CDate(Planning.J2M1S2)
    End If
        If Planning.J3M1S2 = "" Then
        ActiveCell.Offset(11, 0) = ""
        Else: ActiveCell.Offset(11, 0) = CDate(Planning.J3M1S2)
        End If
            If Planning.J4M1S2 = "" Then
            ActiveCell.Offset(12, 0) = ""
            Else: ActiveCell.Offset(12, 0) = CDate(Planning.J4M1S2)
            End If
                If Planning.J5M1S2 = "" Then
                ActiveCell.Offset(13, 0) = ""
                Else: ActiveCell.Offset(13, 0) = CDate(Planning.J5M1S2)
                End If
                    If Planning.J6M1S2 = "" Then
                    ActiveCell.Offset(14, 0) = ""
                    Else: ActiveCell.Offset(14, 0) = CDate(Planning.J6M1S2)
                    End If
                        If Planning.J7M1S2 = "" Then
                        ActiveCell.Offset(15, 0) = ""
                        Else: ActiveCell.Offset(15, 0) = CDate(Planning.J7M1S2)
                        End If
If Planning.J1M2S2 = "" Then
ActiveCell.Offset(9, 1) = ""
Else: ActiveCell.Offset(9, 1) = CDate(Planning.J1M2S2)
End If
    If Planning.J2M2S2 = "" Then
    ActiveCell.Offset(10, 1) = ""
    Else: ActiveCell.Offset(10, 1) = CDate(Planning.J2M2S2)
    End If
        If Planning.J3M2S2 = "" Then
        ActiveCell.Offset(11, 1) = ""
        Else: ActiveCell.Offset(11, 1) = CDate(Planning.J3M2S2)
        End If
            If Planning.J4M2S2 = "" Then
            ActiveCell.Offset(12, 1) = ""
            Else: ActiveCell.Offset(12, 1) = CDate(Planning.J4M2S2)
            End If
                If Planning.J5M2S2 = "" Then
                ActiveCell.Offset(13, 1) = ""
                Else: ActiveCell.Offset(13, 1) = CDate(Planning.J5M2S2)
                End If
                    If Planning.J6M2S2 = "" Then
                    ActiveCell.Offset(14, 1) = ""
                    Else: ActiveCell.Offset(14, 1) = CDate(Planning.J6M2S2)
                    End If
                        If Planning.J7M2S2 = "" Then
                        ActiveCell.Offset(15, 1) = ""
                        Else: ActiveCell.Offset(15, 1) = CDate(Planning.J7M2S2)
                        End If
 
'---------------------- Soir SEMAINE 2 ----------------
If Planning.J1S1S2 = "" Then
ActiveCell.Offset(9, 2) = ""
Else: ActiveCell.Offset(9, 2) = CDate(Planning.J1S1S2)
End If
    If Planning.J2S1S2 = "" Then
    ActiveCell.Offset(10, 2) = ""
    Else: ActiveCell.Offset(10, 2) = CDate(Planning.J2S1S2)
    End If
        If Planning.J3S1S2 = "" Then
        ActiveCell.Offset(11, 2) = ""
        Else: ActiveCell.Offset(11, 2) = CDate(Planning.J3S1S2)
        End If
            If Planning.J4S1S2 = "" Then
            ActiveCell.Offset(12, 2) = ""
            Else: ActiveCell.Offset(12, 2) = CDate(Planning.J4S1S2)
            End If
                If Planning.J5S1S2 = "" Then
                ActiveCell.Offset(13, 2) = ""
                Else: ActiveCell.Offset(13, 2) = CDate(Planning.J5S1S2)
                End If
                    If Planning.J6S1S2 = "" Then
                    ActiveCell.Offset(14, 2) = ""
                    Else: ActiveCell.Offset(14, 2) = CDate(Planning.J6S1S2)
                    End If
                        If Planning.J7S1S2 = "" Then
                        ActiveCell.Offset(15, 2) = ""
                        Else: ActiveCell.Offset(15, 2) = CDate(Planning.J7S1S2)
                        End If
If Planning.J1S2S2 = "" Then
ActiveCell.Offset(9, 3) = ""
Else: ActiveCell.Offset(9, 3) = CDate(Planning.J1S2S2)
End If
    If Planning.J2S2S2 = "" Then
    ActiveCell.Offset(10, 3) = ""
    Else: ActiveCell.Offset(10, 3) = CDate(Planning.J2S2S2)
    End If
        If Planning.J3S2S2 = "" Then
        ActiveCell.Offset(11, 3) = ""
        Else: ActiveCell.Offset(11, 3) = CDate(Planning.J3S2S2)
        End If
            If Planning.J4S2S2 = "" Then
            ActiveCell.Offset(12, 3) = ""
            Else: ActiveCell.Offset(12, 3) = CDate(Planning.J4S2S2)
            End If
                If Planning.J5S2S2 = "" Then
                ActiveCell.Offset(13, 3) = ""
                Else: ActiveCell.Offset(13, 3) = CDate(Planning.J5S2S2)
                End If
                    If Planning.J6S2S2 = "" Then
                    ActiveCell.Offset(14, 3) = ""
                    Else: ActiveCell.Offset(14, 3) = CDate(Planning.J6S2S2)
                    End If
                        If Planning.J7S2S2 = "" Then
                        ActiveCell.Offset(15, 3) = ""
                        Else: ActiveCell.Offset(15, 3) = CDate(Planning.J7S2S2)
                        End If
MsgBox "Le nouveau Planning à bien été créé !"
 
Application.DisplayAlerts = True
' --------------------Rempli la feuille New Collegue -------------
New_Collegue.Fr_ChoixPlanning.Visible = True
New_Collegue.CB_ChoixPlanning = Planning.CB_PlanningBimensuel
 
End
End Sub