Bonjour,

J'ai écris une macro pour effectuer un certain nombre de calcules en se basant sur des parametres contenus sur des feuilles excel, le problème est que le temps de calcule est très long.

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
 
Sub DRP()
 
p = Cells(9, 4)
 
l = 4
 
Date1 = Date
 
 
'une boucle pour commencer à partir de la semaine en cour et sauvegarder l'historique
 
 
Do While Date1 > Cells(5, l)
l = l + 1
Loop
 
For k = 1 To 100
 
 
' on remarque que l'incrémentation commence dès l'index "l"
If Cells(24 + k * 11, 2) < 26 Then
 
For D = l To l + p - 1
 
'condition de point de réappro
 
 
If Cells(20 + k * 11, D) - Cells(23 + k * 11, D) < Cells(21 + k * 11, D) Then
 
 
'><<<<<<<
 
R = Cells(18 + k * 11, D)
 
' Ce bloc sert pour le calcul du besoin en fonction de la couverture cible ça rajoute à chaque fois la cellule de prévisions ayant l'index R+D jusqu'a R=0
 
Do While R > 0
 
Cells(19 + k * 11, D) = Cells(23 + k * 11, D + R - 1) + Cells(19 + k * 11, D)
 
R = R - 1
 
Loop
 
'>>>>>>>
 
' CI après l'équation de stock : Besoin+Stock sécurité-STock début arrondi au multiple du standard palettes
 
If (Cells(19 + k * 11, D) + Cells(22 + k * 11, D) - Cells(20 + k * 11, D)) > 0 Then
 
S = Cells(19 + k * 11, D) + Cells(22 + k * 11, D) - Cells(20 + k * 11, D)
 
Cells(19 + k * 11, D) = Application.WorksheetFunction.MRound(S, Cells(21 + k * 11, 2))
 
Else
 
Cells(19 + k * 11, D) = 0
 
 
'>>>>>>>
 
 
End If
Else
 
Cells(19 + k * 11, D) = 0
End If
 
 
 'ce bloc rajoute une palette au besoin si le stock tombe en négatif
 
If Cells(20 + k * 11, D) < 0 Then
 
Cells(19 + k * 11, D) = Cells(19 + k * 11, D) + Cells(21 + k * 11, 2)
 
End If
'>>>>>>>>>>>>>>>>
Cells(17, D) = Cells(17, D) + Cells(20 + k * 11, D) / Cells(21 + k * 11, 2)
Cells(20, D) = Cells(20, D) + Cells(19 + k * 11, D) / Cells(21 + k * 11, 2)
 
Next
 
 
' Calcul de la couverture glissante a chaque fois le stock est suppérieur aux prévs on compte 6 jours et on soustrait les prév d'une semaine
 
For i = l To l + p
 
 
x = Cells(20 + k * 11, i)
J = i
 
If x > 0 Then
 
Do While x > Cells(23 + k * 11, J)
 
x = x - Cells(23 + k * 11, J)
 
Cells(24 + k * 11, i) = Cells(24 + k * 11, i) + 6
 
J = J + 1
 
Loop
 
 
'>>>>>>>
 
' pour les semaines non totalement couverte on calcul on rajoute le # de jours couverts
 
If Cells(23 + k * 11, J) * 6 > 0 Then
 
 
Cells(24 + k * 11, i) = Cells(24 + k * 11, i) + x / Cells(23 + k * 11, J) * 6
 
Else: Cells(24 + k * 11, i) = ND
 
End If
'>>>>>>>>>>>>>>>>>
 
 
Else: Cells(24 + k * 11, i) = 0
 
 
 
End If
'
 
 
Next
 
End If
 
Next
 
 
End Sub