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
| Function diffstockj8(code_produit As String)
Dim i As Integer
Dim total_stock As Integer
Dim stock As Integer
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
j = ActiveCell.Row
Application.Calculation = xlManual
'je fais la diffstock si c'est un article
If Left(code_produit, 4) <> "CAMP" Then
'je cherche la sortie
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 = 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
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
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
Sheets("PLANNING").Cells(j, 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
Sheets("PLANNING").Cells(j, 21).Value = diffstockj1
Sheets("PLANNING").Cells(j, 22).Value = diffstockj2
Sheets("PLANNING").Cells(j, 23).Value = diffstockj3
'SI C EST UNE CAMPAGNE
ElseIf Left(code_produit, 4) = "CAMP" Then
numligne = Selection.Row
For j = 37 To 500
If Sheets("CODE").Cells(j, 3) = Sheets("PLANNING").Cells(numligne, 4) And Sheets("CODE").Cells(j, 4) = Sheets("PLANNING").Cells(numligne, 5) And Sheets("CODE").Cells(j, 5) = Sheets("PLANNING").Cells(numligne, 6) And Left(Sheets("CODE").Cells(j, 7), 2) = Sheets("PLANNING").Cells(numligne, 7) And Sheets("CODE").Cells(j, 8) = Sheets("PLANNING").Cells(numligne, 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
Exit For
ElseIf 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
Exit For
ElseIf Sheets("PDP Usine 02").Cells(i + 1, 8) = "E" Then
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)
total_cherche_entrej1 = cherche_entrej3 + total_cherche_entrej1
total_cherche_entrej2 = cherche_entrej4 + 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
Exit For
ElseIf Sheets("PDP Usine 02").Cells(i + 2, 8) = "E" Then
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)
total_cherche_entrej1 = cherche_entrej3 + total_cherche_entrej1
total_cherche_entrej2 = cherche_entrej4 + 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
Exit For
Else
cherche_sortiej3 = 0
End If
End If
End If
Next
'je cherche l'entré de l'article s'il y a
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
Next
Sheets("PLANNING").Cells(j, 20).Value = stock
Sheets("PLANNING").Cells(j, 21).Value = diffstockj1
Sheets("PLANNING").Cells(j, 22).Value = diffstockj2
Sheets("PLANNING").Cells(j, 23).Value = diffstockj3
End If
Application.Calculation = xlAutomatic
End Function |
Partager