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
|
Sub MAJ_Generale_PQ()
Dim k, ka, ks, ki As Integer
Dim R As String
Dim PB As String
Dim DL As Long '(dernière ligne de la base)
Dim PL As Long '8
Dim DLT As Long '(dernière ligne du fichier transfert)
Dim name As String
Dim Import As String
Dim store As String
Dim Dc As Integer 'Dernière colonne de la base
Dim plage As Range
Dim ver As String
ver = "070620"
R = 0.2
' Déclaration des fichiers
Dim wb1, wb2, wb3, wb4 As Workbook '(Grande base, Modèle Import Complet)
Dim ws1, ws2, ws3, ws4 As Worksheet
'SOURCE
Set wb1 = ThisWorkbook
Set ws1 = wb1.Worksheets("Epicerie")
'CIBLE 2
Set wb2 = Workbooks.Open("\\Station-serveur\TRANSFERTS DE DONNEES\Modèles\Modèle_Import_PQS_FD-SV.xlsm")
Set ws2 = wb2.Worksheets("PQ")
'CIBLE 3
Set wb3 = Workbooks.Open("\\Station-serveur\\Fichier Exportés AMZ\Modèles\Fichiers pour mise à jour\Flat.File.Price.Inventory.xlsm")
Set ws3 = wb3.Worksheets("Price Template")
'CIBLE 4
Set wb4 = Workbooks.Open("\\Station-serveur\Modèles\Sevellia_Import_File-PQ.xlsm")
Set ws4 = wb4.Worksheets("Products")
'CIBLE 5
Set wb5 = Workbooks.Open("\\Station-serveur\Modèles\FICHIER OFFRES.xlsm")
Set ws5 = wb5.Worksheets("Feuil1")
' RESTRICTION EVENTUELLE DE L'ETENDUE DE L'IMPORT
If MsgBox("Voulez-vous réduire le champ de l'import ?", vbYesNo, "Choix du périmètre") = vbYes Then
PL = InputBox("Entrez la valeur de la première ligne", "Première ligne", 8)
DL = InputBox("Entrez la valeur de la dernière ligne", "Dernière ligne", "DL")
name = InputBox("Entrez un titre pour cet Export:", "Titre de l'Export", "Global")
Else
PL = 8
DL = ws1.Range("F" & Rows.Count).End(xlUp).Row
name = "Global"
End If
MsgBox "L 'étendue de la MAJ va de " & PL & " à " & DL
'BOUCLE DE CREATION DES 4 FICHIERS DE MISE A JOUR GENERALE DES STOCKS
'CIBLE 2
k = 2
For i = PL To DL
'SKU
ws2.Cells(k, 1) = ws1.Cells(i, 1)
ws2.Cells(k + 1, 1) = ws1.Cells(i, 1)
ws2.Cells(k + 2, 1) = ws1.Cells(i, 1)
ws2.Cells(k + 3, 1) = ws1.Cells(i, 1)
ws2.Cells(k + 4, 1) = ws1.Cells(i, 1)
ws2.Cells(k + 5, 1) = ws1.Cells(i, 1)
'LANGUAGE
ws2.Cells(k, 2) = "ru"
ws2.Cells(k + 1, 2) = "en"
ws2.Cells(k + 2, 2) = "fr"
ws2.Cells(k + 3, 2) = "ru"
ws2.Cells(k + 4, 2) = "en"
ws2.Cells(k + 5, 2) = "fr"
'PRIX
ws2.Cells(k, 3) = ws1.Cells(i, 120)
ws2.Cells(k + 1, 3) = ws1.Cells(i, 120)
ws2.Cells(k + 2, 3) = ws1.Cells(i, 120)
ws2.Cells(k + 3, 3) = ws1.Cells(i, 120)
ws2.Cells(k + 4, 3) = ws1.Cells(i, 120)
ws2.Cells(k + 5, 3) = ws1.Cells(i, 120)
'QTY
ws2.Cells(k, 4) = ws1.Cells(i, 122)
ws2.Cells(k + 1, 4) = ws1.Cells(i, 122)
ws2.Cells(k + 2, 4) = ws1.Cells(i, 122)
ws2.Cells(k + 3, 4) = ws1.Cells(i, 122)
ws2.Cells(k + 4, 4) = ws1.Cells(i, 122)
ws2.Cells(k + 5, 4) = ws1.Cells(i, 122)
'STORE
ws2.Cells(k, 5) = "France-delicatessen.fr"
ws2.Cells(k + 1, 5) = "France-delicatessen.fr"
ws2.Cells(k + 2, 5) = "France-delicatessen.fr"
ws2.Cells(k + 3, 5) = "sana-vita.fr"
ws2.Cells(k + 4, 5) = "sana-vita.fr"
ws2.Cells(k + 5, 5) = "sana-vita.fr"
k = k + 6
Next i
'CIBLE 3
ka = 2
For i = PL To DL
'Colonne A = 1 "sku"
ws3.Cells(ka, 1) = ws1.Cells(i, 1)
'Colonne B = 2 "Price"
If choix = "prix-qté" Then ' Choix de la mise à jour, Px/Qté ou Qté seule
ws3.Cells(ka, 2) = ws1.Cells(i, 168)
Else ' MAJ de la Qté seule; la colonen prix reste vide
End If
'Colonne E = 5 "quantity"
ws3.Cells(ka, 5) = ws1.Cells(i, 122)
'Colonne F = 6 "Ledtime-to-ship"
ws3.Cells(ka, 6) = ws1.Cells(i, 169) 'sera utile quand différencié
ka = ka + 1
Next i
'CIBLE 4
ks = 2
For i = PL To DL
'Colonne A = 1 "Vendor Sku"
ws4.Cells(ks, 1) = ws1.Cells(i, 1)
'Colonne B = 2 "Qty"
ws4.Cells(ks, 2) = ws1.Cells(i, 122)
'Colonne C=3 "Price"
ws4.Cells(ks, 3) = ws1.Cells(i, 168) * 0.95
ws4.Cells(ks, 3).NumberFormat = "0.00"
ks = ks + 1
Next i
'CIBLE 5
'Msgbox pour l'opeco: Remise R, dates de début et de fin à préciser
ki = 2
R = 0.2
For i = PL To DL
'Colonne A = 1 "sku"
ws5.Cells(ki, 1) = ws1.Cells(i, 1)
'colonne B = 2 "product-id
ws5.Cells(ki, 1) = ws1.Cells(i, 9)
'Colonne C = 3 "product-id-type
ws5.Cells(ki, 1) = "ean"
'Colonne F = 6 "price"
ws5.Cells(ki, 1) = ws1.Cells(i, 122) * 0.95
'Colonne H = 8 "quantity"
ws5.Cells(ki, 1) = ws1.Cells(i, 122)
'Colonne M = 13 "logistic-class
'Tranche de poids brut calculée à partir du poids brut (96), majoré de l'emballage, poids du carton brut utilisé (193)
PB = (ws1.Cells(i, 96) + ws1.Cells(i, 192)) * 1.05
If PB < 0.25 Then
ws5.Cells(ki, 13) = "MP_PC"
Else
If PB < 0.5 Then
ws5.Cells(ki, 13) = "MP_MC"
Else
If PB < 1 Then
ws5.Cells(ki, 13) = "MP_GC"
Else
If PB < 2 Then
ws5.Cells(ki, 13) = "MP_HG1"
Else
If PB < 4 Then
ws5.Cells(ki, 13) = "MP_HG2"
End If
End If
End If
End If
End If
'Colonne N = 14 "discount-price"
ws5.Cells(ki, 14) = ws1.Cells(i, 122) * 0.95 * R
'Colonne O = 15 "disount-start-end
ws5.Cells(ki, 15) = "TbD"
'Colonne P = 16 "discount-end-date
ws5.Cells(ki, 16) = "TbD"
'Colonne R = 18 "update-delete
ki = ki + 1
Next i
'SAUVEGARDES DES FICHIERS DE MISE A JOUR DES STOCKS
With ws2 'Fichier de mise à jour PQ
ws2.Copy
ActiveWorkbook.SaveAs "\\Station-serveur\C2\PQ\Fichier MAJ PQ_FD_SV " & name & "-" & Format(Now(), "mmdd-hhmm") & ".xlsx"
ActiveWorkbook.Close savechanges:=False
End With
With ws3 'Fichier de mise à jour PQ
ws3.Copy
ActiveWorkbook.SaveAs "\\Station-serveur\C3\FFPI-prix-qté " & name & "-" & Format(Now(), "mmdd-hhmm") & ".xlsx"
ActiveWorkbook.Close savechanges:=False
End With
With ws4 'Fichier de mise à jour PQ
ws4.Copy
ActiveWorkbook.SaveAs "\\Station-serveur\C4\MAJ PQ SEV (v" & ver & ")" & name & "-" & Format(Now(), "mmdd-hhmm") & ".xlsx"
ActiveWorkbook.Close savechanges:=False
End With
With ws5 'Fichier de mise à jour PQ
ws5.Copy
ActiveWorkbook.SaveAs "\\Station-serveur\C5\MAJ PQ INT (v" & ver & ")" & name & "-" & Format(Now(), "mmdd-hhmm") & ".xlsx"
ActiveWorkbook.Close savechanges:=False
End With
End Sub |
Partager