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 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
| Dim retard As Integer
Dim totalretard As Integer
Dim i As Integer
Dim j As Integer
Dim h As Integer
Dim total_stock As Integer
Dim stock As Integer
Dim cellule As Single
Dim diffstockj1 As Integer
Dim diffstockj2 As Integer
Dim diffstockj3 As Integer
Dim diffstockj4 As Integer
Dim diffstockj5 As Integer
Dim diffstockj6 As Integer
Dim diffstockj7 As Integer
Dim code_produit_cherche As String
Dim total_cherche_sortiej1 As Integer
Dim total_cherche_entrej1 As Integer
Dim cherche_sortiej1 As Integer
Dim cherche_entrej1 As Integer
Dim cherche_sortiej2 As Integer
Dim cherche_entrej2 As Integer
Dim total_cherche_sortiej2 As Integer
Dim total_cherche_entrej2 As Integer
Dim cherche_sortiej3 As Integer
Dim cherche_entrej3 As Integer
Dim total_cherche_sortiej3 As Integer
Dim total_cherche_entrej3 As Integer
Dim cherche_sortiej4 As Integer
Dim cherche_entrej4 As Integer
Dim total_cherche_sortiej4 As Integer
Dim total_cherche_entrej4 As Integer
Dim cherche_sortiej5 As Integer
Dim cherche_entrej5 As Integer
Dim total_cherche_sortiej5 As Integer
Dim total_cherche_entrej5 As Integer
Dim cherche_sortiej6 As Integer
Dim cherche_entrej6 As Integer
Dim total_cherche_sortiej6 As Integer
Dim total_cherche_entrej6 As Integer
Dim cherche_sortiej7 As Integer
Dim cherche_entrej7 As Integer
Dim total_cherche_sortiej7 As Integer
Dim total_cherche_entrej7 As Integer
Dim cherche_sortiej8 As Integer
Dim cherche_entrej8 As Integer
Dim total_cherche_sortiej8 As Integer
Dim total_cherche_entrej8 As Integer
Dim rech As String
Dim Plage As Range, Intersection As Range
Dim codegemms As String
Dim code_as As String
Dim variable As String
Set Plage = Range("B4:B200")
Set Intersection = Intersect(Target, Plage)
If Not (Intersection Is Nothing) Then
Application.Calculation = xlManual
'Ici je prend le numéro de mon paramètre même si j'aimerai le mettre en dure. Ici mon paramètre c'est B4 par exemple
h = Target.Row
codegemms = Sheets("PLANNING").Cells(h, 2)
code_produit = Sheets("PLANNING").Cells(h, 2)
Sheets("PLANNING").Cells(h, 3).Value = cherche_produit(codegemms, 2)
Sheets("PLANNING").Cells(h, 4).Value = cherche_produit(codegemms, 3)
Sheets("PLANNING").Cells(h, 5).Value = cherche_produit(codegemms, 4)
Sheets("PLANNING").Cells(h, 6).Value = cherche_produit(codegemms, 5)
Sheets("PLANNING").Cells(h, 7).Value = cherche_produit(codegemms, 7)
Sheets("PLANNING").Cells(h, 8).Value = cherche_produit(codegemms, 8)
Sheets("PLANNING").Cells(h, 9).Value = cherche_produit(codegemms, 9)
Sheets("PLANNING").Cells(h, 10).Value = cherche_produit(codegemms, 6)
'Je regarde si mon code produit commence par CAMP ou pas. Si c'est different de CAMP alors ma réf est un produit.
If Left(code_produit, 4) <> "CAMP" And Left(code_produit, 4) <> "" Then
Sheets("PLANNING").Cells(h, 2).Interior.ColorIndex = 37
'je cherche dans pdp usine le stock à l'instant T et les entre/sortie programmé
For i = 4 To 10000
code_produit_cherche = Sheets("PDP Usine 02").Cells(i, 2)
'si les 4 ligne à la suite son nul alors je quitte la boucle puisqu'il n'y a plus rien derriere
If Sheets("PDP Usine 02").Cells(i, 2) = "" And Sheets("PDP Usine 02").Cells(i + 1, 2) = "" And Sheets("PDP Usine 02").Cells(i + 2, 2) = "" And Sheets("PDP Usine 02").Cells(i + 3, 2) = "" And Sheets("PDP Usine 02").Cells(i + 4, 2) = "" Then
Exit For
Else:
If code_produit_cherche = code_produit Then
stock = Sheets("PDP Usine 02").Cells(i, 8)
If Sheets("PDP Usine 02").Cells(i + 1, 8) = "S" Then
cherche_sortiej1 = Sheets("PDP Usine 02").Cells(i + 1, 11)
cherche_sortiej2 = Sheets("PDP Usine 02").Cells(i + 1, 12)
cherche_sortiej3 = Sheets("PDP Usine 02").Cells(i + 1, 13)
cherche_sortiej4 = Sheets("PDP Usine 02").Cells(i + 1, 14)
cherche_sortiej5 = Sheets("PDP Usine 02").Cells(i + 1, 15)
cherche_sortiej6 = Sheets("PDP Usine 02").Cells(i + 1, 16)
cherche_sortiej7 = Sheets("PDP Usine 02").Cells(i + 1, 17)
cherche_sortiej8 = Sheets("PDP Usine 02").Cells(i + 1, 18)
ElseIf Sheets("PDP Usine 02").Cells(i + 1, 8) = "E" Then
retard = Sheets("PDP Usine 02").Cells(i + 1, 10)
cherche_entrej1 = Sheets("PDP Usine 02").Cells(i + 1, 11)
cherche_entrej2 = Sheets("PDP Usine 02").Cells(i + 1, 12)
cherche_entrej3 = Sheets("PDP Usine 02").Cells(i + 1, 13)
cherche_entrej4 = Sheets("PDP Usine 02").Cells(i + 1, 14)
cherche_entrej5 = Sheets("PDP Usine 02").Cells(i + 1, 15)
cherche_entrej6 = Sheets("PDP Usine 02").Cells(i + 1, 16)
cherche_entrej7 = Sheets("PDP Usine 02").Cells(i + 1, 17)
cherche_entrej8 = Sheets("PDP Usine 02").Cells(i + 1, 18)
End If
If Sheets("PDP Usine 02").Cells(i + 2, 8) = "S" Then
cherche_sortiej1 = Sheets("PDP Usine 02").Cells(i + 2, 11)
cherche_sortiej2 = Sheets("PDP Usine 02").Cells(i + 2, 12)
cherche_sortiej3 = Sheets("PDP Usine 02").Cells(i + 2, 13)
cherche_sortiej4 = Sheets("PDP Usine 02").Cells(i + 2, 14)
cherche_sortiej5 = Sheets("PDP Usine 02").Cells(i + 2, 15)
cherche_sortiej6 = Sheets("PDP Usine 02").Cells(i + 2, 16)
cherche_sortiej7 = Sheets("PDP Usine 02").Cells(i + 2, 17)
cherche_sortiej8 = Sheets("PDP Usine 02").Cells(i + 2, 18)
ElseIf Sheets("PDP Usine 02").Cells(i + 2, 8) = "E" Then
retard = Sheets("PDP Usine 02").Cells(i + 2, 10)
cherche_entrej1 = Sheets("PDP Usine 02").Cells(i + 2, 11)
cherche_entrej2 = Sheets("PDP Usine 02").Cells(i + 2, 12)
cherche_entrej3 = Sheets("PDP Usine 02").Cells(i + 2, 13)
cherche_entrej4 = Sheets("PDP Usine 02").Cells(i + 2, 14)
cherche_entrej5 = Sheets("PDP Usine 02").Cells(i + 2, 15)
cherche_entrej6 = Sheets("PDP Usine 02").Cells(i + 2, 16)
cherche_entrej7 = Sheets("PDP Usine 02").Cells(i + 2, 17)
cherche_entrej8 = Sheets("PDP Usine 02").Cells(i + 2, 18)
End If
Exit For
End If
End If
Next
'jusqu'ici tout va bien je récupère mes valeurs et j'écrit déja mon stock
Sheets("PLANNING").Cells(h, 20).Value = stock
diffstockj1 = Int(cherche_entrej1) + Int(cherche_sortiej1) + Int(stock)
diffstockj2 = Int(cherche_entrej2) + Int(cherche_sortiej2) + diffstockj1
diffstockj3 = Int(cherche_entrej3) + Int(cherche_sortiej3) + diffstockj2
diffstockj4 = Int(cherche_entrej4) + Int(cherche_sortiej4) + diffstockj3
diffstockj5 = Int(cherche_entrej5) + Int(cherche_sortiej5) + diffstockj4
diffstockj6 = Int(cherche_entrej6) + Int(cherche_sortiej6) + diffstockj5
diffstockj7 = Int(cherche_entrej7) + Int(cherche_sortiej7) + diffstockj6
diffstockj8 = Int(cherche_entrej8) + Int(cherche_sortiej8) + diffstockj7
' une fois mes calculs fait j'écrit dans les case correspondante mes valeurs et ma fonction me renvoie diffstock8
Sheets("PLANNING").Cells(h, 21).Value = diffstockj1
Sheets("PLANNING").Cells(h, 22).Value = diffstockj2
Sheets("PLANNING").Cells(h, 23).Value = diffstockj3
Sheets("PLANNING").Cells(h, 24).Value = diffstockj8
If retard <> "0" Then
Sheets("PLANNING").Cells(h, 26).Value = retard
Else
Sheets("PLANNING").Cells(h, 26).Value = ""
End If
'SI C EST UNE CAMPAGNE je vais venir récupérer les codes article correspondant puis je vais faire la même chose que ci dessus
ElseIf Left(code_produit, 4) = "CAMP" Then
Sheets("PLANNING").Cells(h, 2).Interior.ColorIndex = 46
For j = 37 To 500
If Sheets("CODE").Cells(j, 3) = Sheets("PLANNING").Cells(h, 4) And Sheets("CODE").Cells(j, 4) = Sheets("PLANNING").Cells(h, 5) And Sheets("CODE").Cells(j, 5) = Sheets("PLANNING").Cells(h, 6) And Left(Sheets("CODE").Cells(j, 7), 2) = Sheets("PLANNING").Cells(h, 7) And Sheets("CODE").Cells(j, 8) = Sheets("PLANNING").Cells(h, 8) Then
rech = Sheets("CODE").Cells(j, 1)
'Je récupère le code article par rapport à ma campagne
'je cherche la sortie l entre et le stock de l'article s'il y a
For i = 4 To 10000
code_produit_cherche = Sheets("PDP Usine 02").Cells(i, 2)
If Sheets("PDP Usine 02").Cells(i, 2) = "" And Sheets("PDP Usine 02").Cells(i + 1, 2) = "" And Sheets("PDP Usine 02").Cells(i + 2, 2) = "" And Sheets("PDP Usine 02").Cells(i + 3, 2) = "" And Sheets("PDP Usine 02").Cells(i + 4, 2) = "" Then
Exit For
Else:
If code_produit_cherche = rech Then
stock = Sheets("PDP Usine 02").Cells(i, 8)
totalstock = stock + totalstock
If Sheets("PDP Usine 02").Cells(i + 1, 8) = "S" Then
cherche_sortiej1 = Sheets("PDP Usine 02").Cells(i + 1, 11)
cherche_sortiej2 = Sheets("PDP Usine 02").Cells(i + 1, 12)
cherche_sortiej3 = Sheets("PDP Usine 02").Cells(i + 1, 13)
cherche_sortiej4 = Sheets("PDP Usine 02").Cells(i + 1, 14)
cherche_sortiej5 = Sheets("PDP Usine 02").Cells(i + 1, 15)
cherche_sortiej6 = Sheets("PDP Usine 02").Cells(i + 1, 16)
cherche_sortiej7 = Sheets("PDP Usine 02").Cells(i + 1, 17)
cherche_sortiej8 = Sheets("PDP Usine 02").Cells(i + 1, 18)
total_cherche_sortiej1 = cherche_sortiej1 + total_cherche_sortiej1
total_cherche_sortiej2 = cherche_sortiej2 + total_cherche_sortiej2
total_cherche_sortiej3 = cherche_sortiej3 + total_cherche_sortiej3
total_cherche_sortiej4 = cherche_sortiej4 + total_cherche_sortiej4
total_cherche_sortiej5 = cherche_sortiej5 + total_cherche_sortiej5
total_cherche_sortiej6 = cherche_sortiej6 + total_cherche_sortiej6
total_cherche_sortiej7 = cherche_sortiej7 + total_cherche_sortiej7
total_cherche_sortiej8 = cherche_sortiej8 + total_cherche_sortiej8
ElseIf Sheets("PDP Usine 02").Cells(i + 1, 8) = "E" Then
retard = Sheets("PDP Usine 02").Cells(i + 1, 10)
cherche_entrej1 = Sheets("PDP Usine 02").Cells(i + 1, 11)
cherche_entrej2 = Sheets("PDP Usine 02").Cells(i + 1, 12)
cherche_entrej3 = Sheets("PDP Usine 02").Cells(i + 1, 13)
cherche_entrej4 = Sheets("PDP Usine 02").Cells(i + 1, 14)
cherche_entrej5 = Sheets("PDP Usine 02").Cells(i + 1, 15)
cherche_entrej6 = Sheets("PDP Usine 02").Cells(i + 1, 16)
cherche_entrej7 = Sheets("PDP Usine 02").Cells(i + 1, 17)
cherche_entrej8 = Sheets("PDP Usine 02").Cells(i + 1, 18)
totalretard = totalretard + retard
total_cherche_entrej1 = cherche_entrej1 + total_cherche_entrej1
total_cherche_entrej2 = cherche_entrej2 + total_cherche_entrej2
total_cherche_entrej3 = cherche_entrej3 + total_cherche_entrej3
total_cherche_entrej4 = cherche_entrej4 + total_cherche_entrej4
total_cherche_entrej5 = cherche_entrej5 + total_cherche_entrej5
total_cherche_entrej6 = cherche_entrej6 + total_cherche_entrej6
total_cherche_entrej7 = cherche_entrej7 + total_cherche_entrej7
total_cherche_entrej8 = cherche_entrej8 + total_cherche_entrej8
End If
If Sheets("PDP Usine 02").Cells(i + 2, 8) = "S" Then
cherche_sortiej1 = Sheets("PDP Usine 02").Cells(i + 2, 11)
cherche_sortiej2 = Sheets("PDP Usine 02").Cells(i + 2, 12)
cherche_sortiej3 = Sheets("PDP Usine 02").Cells(i + 2, 13)
cherche_sortiej4 = Sheets("PDP Usine 02").Cells(i + 2, 14)
cherche_sortiej5 = Sheets("PDP Usine 02").Cells(i + 2, 15)
cherche_sortiej6 = Sheets("PDP Usine 02").Cells(i + 2, 16)
cherche_sortiej7 = Sheets("PDP Usine 02").Cells(i + 2, 17)
cherche_sortiej8 = Sheets("PDP Usine 02").Cells(i + 2, 18)
total_cherche_sortiej1 = cherche_sortiej1 + total_cherche_sortiej1
total_cherche_sortiej2 = cherche_sortiej2 + total_cherche_sortiej2
total_cherche_sortiej3 = cherche_sortiej3 + total_cherche_sortiej3
total_cherche_sortiej4 = cherche_sortiej4 + total_cherche_sortiej4
total_cherche_sortiej5 = cherche_sortiej5 + total_cherche_sortiej5
total_cherche_sortiej6 = cherche_sortiej6 + total_cherche_sortiej6
total_cherche_sortiej7 = cherche_sortiej7 + total_cherche_sortiej7
total_cherche_sortiej8 = cherche_sortiej8 + total_cherche_sortiej8
ElseIf Sheets("PDP Usine 02").Cells(i + 2, 8) = "E" Then
retard = Sheets("PDP Usine 02").Cells(i + 2, 10)
cherche_entrej1 = Sheets("PDP Usine 02").Cells(i + 2, 11)
cherche_entrej2 = Sheets("PDP Usine 02").Cells(i + 2, 12)
cherche_entrej3 = Sheets("PDP Usine 02").Cells(i + 2, 13)
cherche_entrej4 = Sheets("PDP Usine 02").Cells(i + 2, 14)
cherche_entrej5 = Sheets("PDP Usine 02").Cells(i + 2, 15)
cherche_entrej6 = Sheets("PDP Usine 02").Cells(i + 2, 16)
cherche_entrej7 = Sheets("PDP Usine 02").Cells(i + 2, 17)
cherche_entrej8 = Sheets("PDP Usine 02").Cells(i + 2, 18)
totalretard = totalretard + retard
total_cherche_entrej1 = cherche_entrej1 + total_cherche_entrej1
total_cherche_entrej2 = cherche_entrej2 + total_cherche_entrej2
total_cherche_entrej3 = cherche_entrej3 + total_cherche_entrej3
total_cherche_entrej4 = cherche_entrej4 + total_cherche_entrej4
total_cherche_entrej5 = cherche_entrej5 + total_cherche_entrej5
total_cherche_entrej6 = cherche_entrej6 + total_cherche_entrej6
total_cherche_entrej7 = cherche_entrej7 + total_cherche_entrej7
total_cherche_entrej8 = cherche_entrej8 + total_cherche_entrej8
End If
Exit For
End If
End If
Next
'je fais mes calculs
diffstockj1 = Int(total_cherche_entrej1) + Int(total_cherche_sortiej1) + Int(totalstock)
diffstockj2 = Int(total_cherche_entrej2) + Int(total_cherche_sortiej2) + diffstockj1
diffstockj3 = Int(total_cherche_entrej3) + Int(total_cherche_sortiej3) + diffstockj2
diffstockj4 = Int(total_cherche_entrej4) + Int(total_cherche_sortiej4) + diffstockj3
diffstockj5 = Int(total_cherche_entrej5) + Int(total_cherche_sortiej5) + diffstockj4
diffstockj6 = Int(total_cherche_entrej6) + Int(total_cherche_sortiej6) + diffstockj5
diffstockj7 = Int(total_cherche_entrej7) + Int(total_cherche_sortiej7) + diffstockj6
diffstockj8 = Int(total_cherche_entrej8) + Int(total_cherche_sortiej8) + diffstockj7
End If
If totalretard <> "0" Then
Sheets("PLANNING").Cells(h, 26).Value = totalretard
Else
Sheets("PLANNING").Cells(h, 26).Value = ""
End If
Next
Sheets("PLANNING").Cells(h, 20).Value = totalstock
Sheets("PLANNING").Cells(h, 21).Value = diffstockj1
Sheets("PLANNING").Cells(h, 22).Value = diffstockj2
Sheets("PLANNING").Cells(h, 23).Value = diffstockj3
Sheets("PLANNING").Cells(h, 24).Value = diffstockj8
Else
Sheets("PLANNING").Cells(h, 2).Interior.ColorIndex = 35
End If
code_as = Sheets("PLANNING").Cells(h, 3)
cellule = cherche_moyenne(code_as, h)
If cellule <> "0" Then
Sheets("PLANNING").Cells(h, 27).Value = cellule
Else
Sheets("PLANNING").Cells(h, 27).Value = ""
End If
Application.Calculation = xlAutomatic
End If |
Partager