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 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573
| Sub Création_Tableau()
ind_synth = 2 'indice de ligne pour remplir l'onglet synthèse
Application.Calculation = xlAutomatic
'Mise en page onglet chargement
Sheets("Pl CHarg").Select
Columns("A:AX").Select
Columns("A:AX").EntireColumn.AutoFit
Columns("Q:AX").Select 'On supprime après le S+4
Selection.Delete Shift:=xlToLeft
'Suppression des lignes ne contenant pas de livraisons pour les trois prochaines semaines
Range("Q7").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-4]&RC[-3]&RC[-2]&RC[-1]<>"""",1,0)"
Selection.AutoFill Destination:=Range("Q7:Q5000"), Type:=xlFillDefault
Do Until Cells(ActiveCell.Row, 1) = Empty
If ActiveCell = 0 Then
ActiveCell.EntireRow.Select
Selection.Delete Shift:=xlUp
Cells(ActiveCell.Row, 17).Select
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
Columns("Q:Q").Select
Selection.ClearContents
'XXXXXXXXX
'Fin de préparation de Relance FR
'Fusion des listes France et Export
' Création d'une colonne de resultat
Sheets("Relance FR").Select
Columns("E:E").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
'Recupération nombre de lignes
Sheets("Relance FR").Select
Cells(2, 4).Select
Selection.End(xlDown).Select
num_ligne = ActiveCell.Row
'On copie désormais les renseignements de l'export à la suite dans l'onglet Relance FR
Sheets("Relance EX").Select
Cells(2, 1).Select
i = 1
Do Until ActiveCell = Empty
'On rapatrie le donneur d'ordre dans la colonne division
Sheets("Relance FR").Cells(num_ligne + i, 2) = Cells(ActiveCell.Row, 3)
'On rapatrie le numéro de commande
Sheets("Relance FR").Cells(num_ligne + i, 4) = Cells(ActiveCell.Row, 5)
'On rapatrie l'article
Sheets("Relance FR").Cells(num_ligne + i, 8) = Cells(ActiveCell.Row, 6)
'On rapatrie la désignation
Sheets("Relance FR").Cells(num_ligne + i, 9) = Cells(ActiveCell.Row, 7)
'On rapatrie le gestionnaire
Sheets("Relance FR").Cells(num_ligne + i, 10) = Cells(ActiveCell.Row, 9)
'On rapatrie le RAL
Sheets("Relance FR").Cells(num_ligne + i, 16) = Cells(ActiveCell.Row, 14)
'On rapatrie la date de livraison
Sheets("Relance FR").Cells(num_ligne + i, 19) = Cells(ActiveCell.Row, 17)
i = i + 1
ActiveCell.Offset(1, 0).Select
Loop
'Recupération du nouveau nombre de lignes
Sheets("Relance FR").Select
Cells(2, 4).Select
Selection.End(xlDown).Select
num_ligne = ActiveCell.Row
'Mise au bon format
Columns("D:D").Select
Selection.NumberFormat = "0"
For i = 2 To num_ligne
temp = Cells(i, 4)
Cells(i, 4).Value = temp
Next
'Selection des lignes en cours
Sheets("Pl Charg").Select
Cells(7, 5).Select
Do Until ActiveCell = Empty
commande = ActiveCell
For i = 2 To num_ligne
If Sheets("Relance FR").Cells(i, 4) = commande Then
Sheets("Relance FR").Cells(i, 5) = "X"
End If
Next
ActiveCell.Offset(1, 0).Select
Loop
'Suppression des lignes en trop
Sheets("Relance FR").Select
Range("A2:Z10000").Select
ActiveWorkbook.Worksheets("Relance FR").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Relance FR").Sort.SortFields.Add Key:=Range( _
"E2:E10000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Relance FR").Sort.SortFields.Add Key:=Range( _
"D2:D10000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Relance FR").Sort
.SetRange Range("A2:Z10000")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("E2").Select
Selection.End(xlDown).Select
Range(Cells(ActiveCell.Row + 1, 1), Cells(10000, 26)).Select
Selection.Delete Shift:=xlUp
'Enlève la colonne qui servait de repère
Columns("E:E").Select
Selection.Delete Shift:=xlToLeft
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
'On commence désormais à remplir l'onglet synthèse par son contenu
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
'Nombre de lignes de Relances
Sheets("Relance FR").Select
Cells(2, 4).Select
Selection.End(xlDown).Select
num_lignerel = ActiveCell.Row
'Nombre de lignes de PL Charg
Sheets("Pl Charg").Select
Cells(7, 5).Select
Selection.End(xlDown).Select
num_ligne_plcharg = ActiveCell.Row
'Boucle qui va permettre de remplir la semaine N
Cells(7, 13).Select
Do Until ActiveCell.Row = num_ligne_plcharg + 1
If ActiveCell = "scel" Then
ActiveCell.ClearContents
End If
If ActiveCell <> emtpy Then
cdeclient = ActiveCell.Offset(0, -8)
'i va servir d'indice de boucle et nous permettre de savoir à quel ligne on balaye
For i = 2 To num_lignerel
If Sheets("Relance FR").Cells(i, 4) = cdeclient Then
Sheets("Synthèse").Cells(ind_synth, 1) = Cells(4, 13)
Sheets("Synthèse").Cells(ind_synth, 2) = Sheets("Relance FR").Cells(i, 2)
Sheets("Synthèse").Cells(ind_synth, 3) = ActiveCell.Offset(0, -9)
Sheets("Synthèse").Cells(ind_synth, 4) = Sheets("Relance FR").Cells(i, 4)
Sheets("Synthèse").Cells(ind_synth, 5) = Sheets("Relance FR").Cells(i, 7)
Sheets("Synthèse").Cells(ind_synth, 6) = Sheets("Relance FR").Cells(i, 8)
Sheets("Synthèse").Cells(ind_synth, 7) = Sheets("Relance FR").Cells(i, 9)
Sheets("Synthèse").Cells(ind_synth, 8) = Sheets("Relance FR").Cells(i, 15)
Sheets("Synthèse").Cells(ind_synth, 9) = ActiveCell
Sheets("Synthèse").Cells(ind_synth, 10) = ActiveCell.Offset(0, -1)
Sheets("Synthèse").Cells(ind_synth, 11) = Sheets("Relance FR").Cells(i, 18)
ind_synth = ind_synth + 1
End If
Next
End If
ActiveCell.Offset(1, 0).Select
Loop
'Boucle qui va permettre de remplir la semaine N+1
Cells(7, 14).Select
Do Until ActiveCell.Row = num_ligne_plcharg + 1
If ActiveCell = "scel" Then
ActiveCell.ClearContents
End If
If ActiveCell <> emtpy Then
cdeclient = ActiveCell.Offset(0, -9)
'i va servir d'indice de boucle et nous permettre de savoir à quel ligne on balaye
For i = 2 To num_lignerel
If Sheets("Relance FR").Cells(i, 4) = cdeclient Then
Sheets("Synthèse").Cells(ind_synth, 1) = Cells(4, 14)
Sheets("Synthèse").Cells(ind_synth, 2) = Sheets("Relance FR").Cells(i, 2)
Sheets("Synthèse").Cells(ind_synth, 3) = ActiveCell.Offset(0, -10)
Sheets("Synthèse").Cells(ind_synth, 4) = Sheets("Relance FR").Cells(i, 4)
Sheets("Synthèse").Cells(ind_synth, 5) = Sheets("Relance FR").Cells(i, 7)
Sheets("Synthèse").Cells(ind_synth, 6) = Sheets("Relance FR").Cells(i, 8)
Sheets("Synthèse").Cells(ind_synth, 7) = Sheets("Relance FR").Cells(i, 9)
Sheets("Synthèse").Cells(ind_synth, 8) = Sheets("Relance FR").Cells(i, 15)
Sheets("Synthèse").Cells(ind_synth, 9) = ActiveCell
Sheets("Synthèse").Cells(ind_synth, 10) = ActiveCell.Offset(0, -2)
Sheets("Synthèse").Cells(ind_synth, 11) = Sheets("Relance FR").Cells(i, 18)
ind_synth = ind_synth + 1
End If
Next
End If
ActiveCell.Offset(1, 0).Select
Loop
'Boucle qui va permettre de remplir la semaine N+2
Cells(7, 15).Select
Do Until ActiveCell.Row = num_ligne_plcharg + 1
If ActiveCell = "scel" Then
ActiveCell.ClearContents
End If
If ActiveCell <> emtpy Then
cdeclient = ActiveCell.Offset(0, -10)
'i va servir d'indice de boucle et nous permettre de savoir à quel ligne on balaye
For i = 2 To num_lignerel
If Sheets("Relance FR").Cells(i, 4) = cdeclient Then
Sheets("Synthèse").Cells(ind_synth, 1) = Cells(4, 15)
Sheets("Synthèse").Cells(ind_synth, 2) = Sheets("Relance FR").Cells(i, 2)
Sheets("Synthèse").Cells(ind_synth, 3) = ActiveCell.Offset(0, -11)
Sheets("Synthèse").Cells(ind_synth, 4) = Sheets("Relance FR").Cells(i, 4)
Sheets("Synthèse").Cells(ind_synth, 5) = Sheets("Relance FR").Cells(i, 7)
Sheets("Synthèse").Cells(ind_synth, 6) = Sheets("Relance FR").Cells(i, 8)
Sheets("Synthèse").Cells(ind_synth, 7) = Sheets("Relance FR").Cells(i, 9)
Sheets("Synthèse").Cells(ind_synth, 8) = Sheets("Relance FR").Cells(i, 15)
Sheets("Synthèse").Cells(ind_synth, 9) = ActiveCell
Sheets("Synthèse").Cells(ind_synth, 10) = ActiveCell.Offset(0, -3)
Sheets("Synthèse").Cells(ind_synth, 11) = Sheets("Relance FR").Cells(i, 18)
ind_synth = ind_synth + 1
End If
Next
End If
ActiveCell.Offset(1, 0).Select
Loop
'Boucle qui va permettre de remplir la semaine N+3
Cells(7, 16).Select
Do Until ActiveCell.Row = num_ligne_plcharg + 1
If ActiveCell = "scel" Then
ActiveCell.ClearContents
End If
If ActiveCell <> emtpy Then
cdeclient = ActiveCell.Offset(0, -11)
'i va servir d'indice de boucle et nous permettre de savoir à quel ligne on balaye
For i = 2 To num_lignerel
If Sheets("Relance FR").Cells(i, 4) = cdeclient Then
Sheets("Synthèse").Cells(ind_synth, 1) = Cells(4, 16)
Sheets("Synthèse").Cells(ind_synth, 2) = Sheets("Relance FR").Cells(i, 2)
Sheets("Synthèse").Cells(ind_synth, 3) = ActiveCell.Offset(0, -12)
Sheets("Synthèse").Cells(ind_synth, 4) = Sheets("Relance FR").Cells(i, 4)
Sheets("Synthèse").Cells(ind_synth, 5) = Sheets("Relance FR").Cells(i, 7)
Sheets("Synthèse").Cells(ind_synth, 6) = Sheets("Relance FR").Cells(i, 8)
Sheets("Synthèse").Cells(ind_synth, 7) = Sheets("Relance FR").Cells(i, 9)
Sheets("Synthèse").Cells(ind_synth, 8) = Sheets("Relance FR").Cells(i, 15)
Sheets("Synthèse").Cells(ind_synth, 9) = ActiveCell
Sheets("Synthèse").Cells(ind_synth, 10) = ActiveCell.Offset(0, -4)
Sheets("Synthèse").Cells(ind_synth, 11) = Sheets("Relance FR").Cells(i, 18)
ind_synth = ind_synth + 1
End If
Next
End If
ActiveCell.Offset(1, 0).Select
Loop
'xxxxxxx
'Mise en page de l'onglet de synthèse
'Centrer la colonne A
Sheets("Synthèse").Select
Columns("A:A").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
'Boucle pour une couleur par semaine
Cells(2, 1).Select
semaine = ActiveCell
Do Until ActiveCell <> semaine
'Format semaine N
Application.CutCopyMode = False
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
Selection.Font.Bold = True
ActiveCell.Offset(1, 0).Select
Loop
semaine = ActiveCell
Do Until ActiveCell <> semaine
'Format semaine N+1
Application.CutCopyMode = False
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 49407
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ActiveCell.Offset(1, 0).Select
Loop
semaine = ActiveCell
Do Until ActiveCell = Empty
If ActiveCell = semaine Then
'Semaine N+2
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 49407
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Else
'Semaine N+3
'Pour l'instant pas de couleur pour S+3
End If
ActiveCell.Offset(1, 0).Select
Loop
Range("A1").Select
ActiveCell.FormulaR1C1 = "Semaine"
Range("B1").Select
ActiveCell.FormulaR1C1 = "Client"
Range("C1").Select
ActiveCell.FormulaR1C1 = "Chantier"
Range("D1").Select
ActiveCell.FormulaR1C1 = "Commande"
Range("E1").Select
ActiveCell.FormulaR1C1 = "Article"
Range("F1").Select
ActiveCell.FormulaR1C1 = "Désignation"
Range("G1").Select
ActiveCell.FormulaR1C1 = "Gestio."
Range("H1").Select
ActiveCell.FormulaR1C1 = "RAL"
Range("I1").Select
ActiveCell.FormulaR1C1 = "Mob sem."
Range("J1").Select
ActiveCell.FormulaR1C1 = "Mob tot."
Range("K1").Select
ActiveCell.FormulaR1C1 = "Date livr."
Range("L1").Select
ActiveCell.FormulaR1C1 = "Date gest."
Range("A1:L1").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorLight2
.TintAndShade = -0.499984740745262
.PatternTintAndShade = 0
End With
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
Selection.Font.Bold = True
Range(Selection, Selection.End(xlDown)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Columns("C:C").ColumnWidth = 16
Columns("A:A").ColumnWidth = 8.29
Columns("D:D").Select
Selection.ColumnWidth = 13.14
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("E:E").ColumnWidth = 15.29
Columns("F:F").ColumnWidth = 41.43
Columns("G:G").ColumnWidth = 7.86
Columns("H:H").ColumnWidth = 8.29
Columns("H:H").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("I:J").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("K:K").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.NumberFormat = "dd/mm/yy;@"
Columns("K:K").Select
Selection.ColumnWidth = 10.86
Columns("L:L").Select
Selection.ColumnWidth = 13
Columns("I:I").Select
Selection.ColumnWidth = 7.57
Selection.ColumnWidth = 9.71
Columns("J:J").Select
Selection.ColumnWidth = 10.43
Columns("B:B").Select
Selection.ColumnWidth = 8
'Trier par semaine puis par num commande
Columns("A:L").Select
ActiveWorkbook.Worksheets("Synthèse").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Synthèse").Sort.SortFields.Add Key:=Range( _
"A2:A638"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Synthèse").Sort.SortFields.Add Key:=Range( _
"D2:D638"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Synthèse").Sort
.SetRange Range("A1:L638")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'Création d'un mini indicateur qui permet de savoir si on est sur la même commande que la ligne du dessus
Range("M2").Select
ActiveCell.FormulaR1C1 = "=1"
Range("M3").Select
Do Until ActiveCell.Offset(0, -7) = Empty
ActiveCell.FormulaR1C1 = "=IF(RC[-9]=R[-1]C[-9],R[-1]C,R[-1]C*-1)"
ActiveCell.Offset(1, 0).Select
Loop
Range("M2").Select
'Création d'une différenciation de couleur entre commande
Do Until ActiveCell.Offset(0, -7) = Empty
If ActiveCell = -1 Then
Range(ActiveCell.Offset(0, -11), ActiveCell.Offset(0, -1)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent1
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
End If
Cells(ActiveCell.Row + 1, 13).Select
Loop
Columns("M:M").Select
Selection.Delete Shift:=xlToLeft
'Petite amélioration de la mise en forme
Columns("J:J").Select
Selection.NumberFormat = "General"
Columns("L:L").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("L1").Select
ActiveCell.FormulaR1C1 = "ADV"
End Sub |
Partager