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
| Sub ajout_plato(Qte_Cart, NbCartPlato, MotCle, Type_Cart, k)
'***********************************************************
'* Cas d'insuffisance de place recherche de plateau libre *
'***********************************************************
Dim lg As Byte
Dim fini As Byte
Dim tablo() As Variant
Dim Sortie_Tablo()
Dim Stockeur As String
Dim Plateau As String
'____Ceci est dans la macro Zone_Nommee__appelee par "entré_en_stock"_____
'With ActiveWorkbook.Names
' .Add Name:="StoKeRA", RefersTo:="=Donnees!$O$2:$O$" & StocRA
' .Add Name:="StoKeRB", RefersTo:="=Donnees!$P$2:$P$" & StocRB
' .Add Name:="StoKeRC", RefersTo:="=Donnees!$Q$2:$Q$" & StocRC
' .Add Name:="StoKeRD", RefersTo:="=Donnees!$R$2:$R$" & StocRD
'End With
'__et défini les quatre stockeurs A B C et D
lg = Sheets("stock").Range("a65535").End(xlUp).Row + 1
a = 0
Sheets("Donnees").Select
'Recherche des vides dans le stockeur A
For Each cel In Range("StokeRA")
If cel = 0 Then
Plateau = Cells(cel.Row, 6).Value
Stockeur = Cells(1, cel.Column).Value
ReDim Preserve tablo(5, a)
If Qte_Cart > NbCartPlato Then
tablo(0, a) = lg
tablo(1, a) = MotCle
tablo(2, a) = NbCartPlato
tablo(3, a) = Plateau
tablo(4, a) = Stockeur
tablo(5, a) = Type_Cart
Qte_Cart = Qte_Cart - NbCartPlato
a = a + 1
lg = lg + 1
Else
tablo(0, a) = lg
tablo(1, a) = MotCle
tablo(2, a) = Qte_Cart
tablo(3, a) = Cells(cel.Row, 6).Value
tablo(4, a) = Cells(1, cel.Column).Value
tablo(5, a) = Type_Cart
Qte_Cart = 0
a = a + 1
lg = lg + 1
fini = 1
Exit For
End If
End If
Next
If fini = 0 Then
'Recherche des vide dans la stockeur B
For Each cel In Range("StokeRB")
If cel = 0 Then
Plateau = Cells(cel.Row, 6).Value
Stockeur = Cells(1, cel.Column).Value
ReDim Preserve tablo(5, a)
If Qte_Cart > NbCartPlato Then
tablo(0, a) = lg
tablo(1, a) = MotCle
tablo(2, a) = NbCartPlato
tablo(3, a) = Plateau
tablo(4, a) = Stockeur
tablo(5, a) = Type_Cart
Qte_Cart = Qte_Cart - NbCartPlato
a = a + 1
lg = lg + 1
Else
tablo(0, a) = lg
tablo(1, a) = MotCle
tablo(2, a) = Qte_Cart
tablo(3, a) = Cells(cel.Row, 6).Value
tablo(4, a) = Cells(1, cel.Column).Value
tablo(5, a) = Type_Cart
Qte_Cart = 0
a = a + 1
lg = lg + 1
fini = 1
Exit For
End If
End If
Next
If fini = 0 Then
'Recherche des vide dans la stockeur C
For Each cel In Range("StokeRC")
If cel = 0 Then
Plateau = Cells(cel.Row, 6).Value
Stockeur = Cells(1, cel.Column).Value
ReDim Preserve tablo(5, a)
If Qte_Cart > NbCartPlato Then
tablo(0, a) = lg
tablo(1, a) = MotCle
tablo(2, a) = NbCartPlato
tablo(3, a) = Plateau
tablo(4, a) = Stockeur
tablo(5, a) = Type_Cart
Qte_Cart = Qte_Cart - NbCartPlato
a = a + 1
lg = lg + 1
Else
tablo(0, a) = lg
tablo(1, a) = MotCle
tablo(2, a) = Qte_Cart
tablo(3, a) = Cells(cel.Row, 6).Value
tablo(4, a) = Cells(1, cel.Column).Value
tablo(5, a) = Type_Cart
Qte_Cart = 0
a = a + 1
lg = lg + 1
fini = 1
Exit For
End If
End If
Next
If fini = 0 Then
'Recherche des vides dans la stockeur D
For Each cel In Range("StokeRD")
If cel = 0 Then
Plateau = Cells(cel.Row, 6).Value
Stockeur = Cells(1, cel.Column).Value
ReDim Preserve tablo(5, a)
If Qte_Cart > NbCartPlato Then
tablo(0, a) = lg
tablo(1, a) = MotCle
tablo(2, a) = NbCartPlato
tablo(3, a) = Plateau
tablo(4, a) = Stockeur
tablo(5, a) = Type_Cart
Qte_Cart = Qte_Cart - NbCartPlato
a = a + 1
lg = lg + 1
Else
tablo(0, a) = lg
tablo(1, a) = MotCle
tablo(2, a) = Qte_Cart
tablo(3, a) = Cells(cel.Row, 6).Value
tablo(4, a) = Cells(1, cel.Column).Value
tablo(5, a) = Type_Cart
Qte_Cart = 0
a = a + 1
lg = lg + 1
fini = 1
Exit For
End If
End If
Next
End If
End If
End If
a = a - 1 'annulation de la derniere incrementation
ReDim Preserve Sortie_Tablo(a, 5)
For t = 0 To a
For j = 0 To 5
Sortie_Tablo(t, j) = tablo(j, t)
Next j
Next t
Sheets("mouvements").Select
Range("k" & k & ":p" & k + a).Value = Sortie_Tablo
Dim y As Byte
If Range("a1").Value = "" Then
y = 1
Else
y = Range("a65535").End(xlUp).Row + 1
End If
Range("a" & y & ":f" & y + a).Value = Sortie_Tablo
End Sub |
Partager