IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

Procedure trop longue


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2017
    Messages
    23
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Mai 2017
    Messages : 23
    Par défaut Procedure trop longue
    Bonjour la famille
    J'ai besoin de votre aide SVP , je suis débutant en VBA , j'ai élaboré une Macro qui permet de faire des claculs automatiques à partir des différentes feuilles dans le mm woorkbook , mais vers la fin quand je voulais exécuté la macro ça marche pas en m'affichant le message " Procedure trop longue" .
    Quelqu'un pourrait me donner une solution à ce problème ?
    Merci

  2. #2
    Invité
    Invité(e)
    Par défaut
    Bonjour,
    au vue de ton code, je dirai faire une procédure moins longue!

  3. #3
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2017
    Messages
    23
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Mai 2017
    Messages : 23
    Par défaut
    Bonjour , Voici mon Code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
     
    Sub path_Region()
    If Sheets("1").ComboBox1.Value = "NA" Then
    If Sheets("1").ComboBox4.Value = "Retail" Then
    Worksheets("P_NA_Retail").Select
    Else
    Worksheets("P_NA_HOD").Select
    End If
    Else:
    If Sheets("1").ComboBox1.Value = "IT" Then
    Worksheets("P_IT").Select
    Else
    If Sheets("1").ComboBox1.Value = "FRBE" Then
    Worksheets("P_FRBE").Select
    Else
    If Sheets("1").ComboBox1.Value = "EUROP" Then
    Worksheets("P_EUROPE").Select
    Else:
    If Sheets("1").ComboBox1.Value = "AOA" Then
    If Sheets("1").ComboBox4.Value = "Retail" Then
    Worksheets("P_AOA_Retail").Select
    Else
    Worksheets("P_AOA_HOD").Select
    End If
    Else
    If Sheets("1").ComboBox1.Value = "Latam" Then
    Worksheets("P_Latam_Retail").Select
    End If
    End If
    End If
    End If
    End If
    End If
    Dim Brand As String, Country As String
    Country = Sheets("1").ComboBox2.Value
    Brand = Sheets("1").ComboBox3.Value
    If ActiveSheet.Name = "P_NA_Retail" Or ActiveSheet.Name = "P_NA_HOD" And ActiveSheet.Name = "P_IT" Then
    GoTo No_country
    End If
    Set Cellule_Country = ActiveSheet.Range("A1:BK1").Find(Country, lookat:=xlWhole)
    Ligne_Country = Cellule_Country.Row
    col_Country = Cellule_Country.Column
    Set Cellule_Brand = ActiveSheet.Range(Cells(1, col_Country), Cells(620, col_Country)).Find(Brand, lookat:=xlWhole)
    Ligne_Brand = Cellule_Brand.Row
    Col_Brand = Cellule_Brand.Column
    No_country:
    Set Cellule_Brand = ActiveSheet.Range("A1:BK620").Find(Brand, lookat:=xlWhole)
    Ligne_Brand = Cellule_Brand.Row
    Col_Brand = Cellule_Brand.Column
     
    ' l le numéro de ligne ou commence Direct'
    l = Ligne_Brand + 3
    Do While ActiveSheet.Cells(l, Col_Brand - 4).Value <> 2 And l <= Ligne_Brand + 68
    l = l + 1
    Loop
     
    ' p le numéro de ligne ou commence Indirect'
    P = l
    Do While ActiveSheet.Cells(P, Col_Brand - 4).Value <> 3 And P <= Ligne_Brand + 68
    P = P + 1
    Loop
     
    ' q le numéro de ligne ou finit indirect +1'
    q = P
    Do While ActiveSheet.Cells(q, Col_Brand - 4).Value <> 4 And q <= Ligne_Brand + 68
    q = q + 1
    Loop
     
    'Supply"""""""""""""""
    ' DL_S et l'indice du la dernière non vide de la sheet"supply"'
    DL_S = 0
    Do While Not IsEmpty(Sheets("Supply").Cells(DL_S + 1, 1))
    DL_S = DL_S + 1
    Loop
    If ActiveSheet.Name = "P_EUROPE" Then
    Sheets("Supply").Activate
    For j = Ligne_Brand + 3 To l - 1
    'Somme de volume
    Sheets("P_EUROPE").Cells(j, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "E"), Cells(DL_S, "E")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_EUROPE").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_EUROPE").Cells(j, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_EUROPE").Cells(j, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "L"), Cells(DL_S, "L")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_EUROPE").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_EUROPE").Cells(j, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("p_EUROPE").Cells(j, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "P"), Cells(DL_S, "P")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("p_EUROPE").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("p_EUROPE").Cells(j, Col_Brand - 2))
    If Sheets("p_EUROPE").Cells(j, Col_Brand - 2).Value = "Truck" Then
    'Somme de TKM truck
    Sheets("p_EUROPE").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "M"), Cells(DL_S, "M")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("p_EUROPE").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("p_EUROPE").Cells(j, Col_Brand - 2))
    Else
    If Sheets("p_EUROPE").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("p_EUROPE").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "N"), Cells(DL_S, "N")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("p_EUROPE").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("p_EUROPE").Cells(j, Col_Brand - 2))
    Else
    If Sheets("p_EUROPE").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("p_EUROPE").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "O"), Cells(DL_S, "O")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("p_EUROPE").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("p_EUROPE").Cells(j, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("p_EUROPE").Cells(j, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "Q"), Cells(DL_S, "Q")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("p_EUROPE").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("p_EUROPE").Cells(j, Col_Brand - 2))
    Next j
    '________________________________________________________________________________________________
    'Direct"""""""""""""""
    ' DL_D et l'indice du la dernière non vide de la sheet"Direct"'
    DL_D = 0
    Do While Not IsEmpty(Sheets("Direct").Cells(DL_D + 1, 1))
    DL_D = DL_D + 1
    Loop
    Sheets("Direct").Activate
    For jj = l To P - 1
    'Somme de volume
    Sheets("p_EUROPE").Cells(jj, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "G"), Cells(DL_D, "G")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("p_EUROPE").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("p_EUROPE").Cells(jj, Col_Brand - 2))
    'Somme de total liters
    Sheets("p_EUROPE").Cells(jj, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "O"), Cells(DL_D, "O")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("p_EUROPE").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("p_EUROPE").Cells(jj, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("p_EUROPE").Cells(jj, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "S"), Cells(DL_D, "S")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("p_EUROPE").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("p_EUROPE").Cells(jj, Col_Brand - 2))
    If Sheets("p_EUROPE").Cells(j, Col_Brand - 2) = "Truck" Then
    'Somme de TKM truck
    Sheets("p_EUROPE").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "P"), Cells(DL_D, "P")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("p_EUROPE").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("p_EUROPE").Cells(jj, Col_Brand - 2))
    Else
    If Sheets("p_EUROPE").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("p_EUROPE").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "Q"), Cells(DL_D, "Q")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("p_EUROPE").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("p_EUROPE").Cells(jj, Col_Brand - 2))
    Else
    If Sheets("p_EUROPE").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("p_EUROPE").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "R"), Cells(DL_D, "R")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("p_EUROPE").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("p_EUROPE").Cells(jj, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("p_EUROPE").Cells(jj, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "T"), Cells(DL_D, "T")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("p_EUROPE").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("p_EUROPE").Cells(jj, Col_Brand - 2))
    Next jj
    '_________________________________________________________________________________________________________
    'Indirect"""""""""""""""
    ' DL_I et l'indice du la dernière non vide de la sheet"InDirect"'
    DL_I = 0
    Do While Not IsEmpty(Sheets("Indirect").Cells(DL_I + 1, 1))
    DL_I = DL_I + 1
    Loop
    Sheets("Indirect").Activate
    For jjj = P To q - 1
    'Somme de volume
    Sheets("p_EUROPE").Cells(jjj, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "G"), Cells(DL_I, "G")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("p_EUROPE").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("p_EUROPE").Cells(jjj, Col_Brand - 2))
    'Somme de total liters
    Sheets("p_EUROPE").Cells(jjj, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "O"), Cells(DL_I, "O")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("p_EUROPE").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("p_EUROPE").Cells(jjj, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("p_EUROPE").Cells(jjj, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "S"), Cells(DL_I, "S")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("p_EUROPE").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("p_EUROPE").Cells(jjj, Col_Brand - 2))
    If Sheets("p_EUROPE").Cells(j, Col_Brand - 2) = "Truck" Then
    'Somme de TKM truck
    Sheets("p_EUROPE").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "P"), Cells(DL_I, "P")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("p_EUROPE").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("p_EUROPE").Cells(jjj, Col_Brand - 2))
    Else
    If Sheets("p_EUROPE").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("p_EUROPE").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "Q"), Cells(DL_I, "Q")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("p_EUROPE").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("p_EUROPE").Cells(jjj, Col_Brand - 2))
    Else
    If Sheets("p_EUROPE").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("p_EUROPE").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "R"), Cells(DL_I, "R")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("p_EUROPE").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("p_EUROPE").Cells(jjj, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("p_EUROPE").Cells(jjj, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "T"), Cells(DL_I, "T")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("p_EUROPE").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("p_EUROPE").Cells(jjj, Col_Brand - 2))
    Next jjj
    End If
    If ActiveSheet.Name = "P_FRBE" Then
    Sheets("Supply").Activate
    For j = Ligne_Brand + 3 To l - 1
    'Somme de volume
    Sheets("P_FRBE").Cells(j, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "E"), Cells(DL_S, "E")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_FRBE").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_FRBE").Cells(j, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_FRBE").Cells(j, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "L"), Cells(DL_S, "L")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_FRBE").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_FRBE").Cells(j, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_FRBE").Cells(j, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "P"), Cells(DL_S, "P")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_FRBE").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_FRBE").Cells(j, Col_Brand - 2))
    If Sheets("P_FRBE").Cells(j, Col_Brand - 2).Value = "Truck" Then
    'Somme de TKM truck
    Sheets("P_FRBE").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "M"), Cells(DL_S, "M")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_FRBE").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_FRBE").Cells(j, Col_Brand - 2))
    Else
    If Sheets("P_FRBE").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_FRBE").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "N"), Cells(DL_S, "N")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_FRBE").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_FRBE").Cells(j, Col_Brand - 2))
    Else
    If Sheets("P_FRBE").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_FRBE").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "O"), Cells(DL_S, "O")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_FRBE").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_FRBE").Cells(j, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_FRBE").Cells(j, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "Q"), Cells(DL_S, "Q")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_FRBE").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_FRBE").Cells(j, Col_Brand - 2))
    Next j
    '________________________________________________________________________________________________
    'Direct"""""""""""""""
    ' DL_D et l'indice du la dernière non vide de la sheet"Direct"'
    DL_D = 0
    Do While Not IsEmpty(Sheets("Direct").Cells(DL_D + 1, 1))
    DL_D = DL_D + 1
    Loop
    Sheets("Direct").Activate
    For jj = l To P - 1
    'Somme de volume
    Sheets("P_FRBE").Cells(jj, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "G"), Cells(DL_D, "G")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_FRBE").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_FRBE").Cells(jj, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_FRBE").Cells(jj, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "O"), Cells(DL_D, "O")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_FRBE").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_FRBE").Cells(jj, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_FRBE").Cells(jj, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "S"), Cells(DL_D, "S")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_FRBE").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_FRBE").Cells(jj, Col_Brand - 2))
    If Sheets("P_FRBE").Cells(j, Col_Brand - 2) = "Truck" Then
    'Somme de TKM truck
    Sheets("P_FRBE").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "P"), Cells(DL_D, "P")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_FRBE").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_FRBE").Cells(jj, Col_Brand - 2))
    Else
    If Sheets("P_FRBE").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_FRBE").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "Q"), Cells(DL_D, "Q")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_FRBE").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_FRBE").Cells(jj, Col_Brand - 2))
    Else
    If Sheets("P_FRBE").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_FRBE").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "R"), Cells(DL_D, "R")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_FRBE").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_FRBE").Cells(jj, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_FRBE").Cells(jj, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "T"), Cells(DL_D, "T")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_FRBE").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_FRBE").Cells(jj, Col_Brand - 2))
    Next jj
    '_________________________________________________________________________________________________________
    'Indirect"""""""""""""""
    ' DL_I et l'indice du la dernière non vide de la sheet"InDirect"'
    DL_I = 0
    Do While Not IsEmpty(Sheets("Indirect").Cells(DL_I + 1, 1))
    DL_I = DL_I + 1
    Loop
    Sheets("Indirect").Activate
    For jjj = P To q - 1
    'Somme de volume
    Sheets("P_FRBE").Cells(jjj, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "G"), Cells(DL_I, "G")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_FRBE").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_FRBE").Cells(jjj, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_FRBE").Cells(jjj, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "O"), Cells(DL_I, "O")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_FRBE").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_FRBE").Cells(jjj, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_FRBE").Cells(jjj, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "S"), Cells(DL_I, "S")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_FRBE").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_FRBE").Cells(jjj, Col_Brand - 2))
    If Sheets("P_FRBE").Cells(j, Col_Brand - 2) = "Truck" Then
    'Somme de TKM truck
    Sheets("P_FRBE").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "P"), Cells(DL_I, "P")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_FRBE").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_FRBE").Cells(jjj, Col_Brand - 2))
    Else
    If Sheets("P_FRBE").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_FRBE").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "Q"), Cells(DL_I, "Q")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_FRBE").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_FRBE").Cells(jjj, Col_Brand - 2))
    Else
    If Sheets("P_FRBE").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_FRBE").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "R"), Cells(DL_I, "R")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_FRBE").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_FRBE").Cells(jjj, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_FRBE").Cells(jjj, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "T"), Cells(DL_I, "T")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_FRBE").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_FRBE").Cells(jjj, Col_Brand - 2))
    Next jjj
    End If
    If ActiveSheet.Name = "P_NA_Retail" Then
    Sheets("Supply").Activate
    For j = Ligne_Brand + 3 To l - 1
    'Somme de volume
    Sheets("P_NA_Retail").Cells(j, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "E"), Cells(DL_S, "E")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_Retail").Cells(j, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_NA_Retail").Cells(j, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "L"), Cells(DL_S, "L")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_Retail").Cells(j, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_NA_Retail").Cells(j, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "P"), Cells(DL_S, "P")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_Retail").Cells(j, Col_Brand - 2))
    If Sheets("P_NA_Retail").Cells(j, Col_Brand - 2).Value = "Truck" Then
    'Somme de TKM truck
    Sheets("P_NA_Retail").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "M"), Cells(DL_S, "M")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_Retail").Cells(j, Col_Brand - 2))
    Else
    If Sheets("P_NA_Retail").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_NA_Retail").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "N"), Cells(DL_S, "N")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_Retail").Cells(j, Col_Brand - 2))
    Else
    If Sheets("P_NA_Retail").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_NA_Retail").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "O"), Cells(DL_S, "O")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_Retail").Cells(j, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_NA_Retail").Cells(j, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "Q"), Cells(DL_S, "Q")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_Retail").Cells(j, Col_Brand - 2))
    Next j
    '________________________________________________________________________________________________
    'Direct"""""""""""""""
    ' DL_D et l'indice du la dernière non vide de la sheet"Direct"'
    DL_D = 0
    Do While Not IsEmpty(Sheets("Direct").Cells(DL_D + 1, 1))
    DL_D = DL_D + 1
    Loop
    Sheets("Direct").Activate
    For jj = l To P - 1
    'Somme de volume
    Sheets("P_NA_Retail").Cells(jj, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "G"), Cells(DL_D, "G")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_Retail").Cells(jj, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_NA_Retail").Cells(jj, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "O"), Cells(DL_D, "O")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_Retail").Cells(jj, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_NA_Retail").Cells(jj, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "S"), Cells(DL_D, "S")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_Retail").Cells(jj, Col_Brand - 2))
    If Sheets("P_NA_Retail").Cells(j, Col_Brand - 2) = "Truck" Then
    'Somme de TKM truck
    Sheets("P_NA_Retail").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "P"), Cells(DL_D, "P")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_Retail").Cells(jj, Col_Brand - 2))
    Else
    If Sheets("P_NA_Retail").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_NA_Retail").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "Q"), Cells(DL_D, "Q")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_Retail").Cells(jj, Col_Brand - 2))
    Else
    If Sheets("P_NA_Retail").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_NA_Retail").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "R"), Cells(DL_D, "R")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_Retail").Cells(jj, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_NA_Retail").Cells(jj, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "T"), Cells(DL_D, "T")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_Retail").Cells(jj, Col_Brand - 2))
    Next jj
    '_________________________________________________________________________________________________________
    'Indirect"""""""""""""""
    ' DL_I et l'indice du la dernière non vide de la sheet"InDirect"'
    DL_I = 0
    Do While Not IsEmpty(Sheets("Indirect").Cells(DL_I + 1, 1))
    DL_I = DL_I + 1
    Loop
    Sheets("Indirect").Activate
    For jjj = P To q - 1
    'Somme de volume
    Sheets("P_NA_Retail").Cells(jjj, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "G"), Cells(DL_I, "G")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_NA_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_Retail").Cells(jjj, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_NA_Retail").Cells(jjj, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "O"), Cells(DL_I, "O")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_NA_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_Retail").Cells(jjj, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_NA_Retail").Cells(jjj, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "S"), Cells(DL_I, "S")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_NA_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_Retail").Cells(jjj, Col_Brand - 2))
    If Sheets("P_NA_Retail").Cells(j, Col_Brand - 2) = "Truck" Then
    'Somme de TKM truck
    Sheets("P_NA_Retail").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "P"), Cells(DL_I, "P")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_NA_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_Retail").Cells(jjj, Col_Brand - 2))
    Else
    If Sheets("P_NA_Retail").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_NA_Retail").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "Q"), Cells(DL_I, "Q")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_NA_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_Retail").Cells(jjj, Col_Brand - 2))
    Else
    If Sheets("P_NA_Retail").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_NA_Retail").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "R"), Cells(DL_I, "R")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_NA_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_Retail").Cells(jjj, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_NA_Retail").Cells(jjj, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "T"), Cells(DL_I, "T")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_NA_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_Retail").Cells(jjj, Col_Brand - 2))
    Next jjj
    End If
    If ActiveSheet.Name = "P_NA_HOD" Then
    Sheets("Supply").Activate
    For j = Ligne_Brand + 3 To l - 1
    'Somme de volume
    Sheets("P_NA_HOD").Cells(j, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "E"), Cells(DL_S, "E")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_HOD").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_HOD").Cells(j, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_NA_HOD").Cells(j, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "L"), Cells(DL_S, "L")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_HOD").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_HOD").Cells(j, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_NA_HOD").Cells(j, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "P"), Cells(DL_S, "P")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_HOD").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_HOD").Cells(j, Col_Brand - 2))
    If Sheets("P_NA_HOD").Cells(j, Col_Brand - 2).Value = "Truck" Then
    'Somme de TKM truck
    Sheets("P_NA_HOD").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "M"), Cells(DL_S, "M")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_HOD").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_HOD").Cells(j, Col_Brand - 2))
    Else
    If Sheets("P_NA_HOD").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_NA_HOD").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "N"), Cells(DL_S, "N")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_HOD").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_HOD").Cells(j, Col_Brand - 2))
    Else
    If Sheets("P_NA_HOD").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_NA_HOD").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "O"), Cells(DL_S, "O")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_HOD").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_HOD").Cells(j, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_NA_HOD").Cells(j, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "Q"), Cells(DL_S, "Q")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_HOD").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_HOD").Cells(j, Col_Brand - 2))
    Next j
    '________________________________________________________________________________________________
    'Direct"""""""""""""""
    ' DL_D et l'indice du la dernière non vide de la sheet"Direct"'
    DL_D = 0
    Do While Not IsEmpty(Sheets("Direct").Cells(DL_D + 1, 1))
    DL_D = DL_D + 1
    Loop
    Sheets("Direct").Activate
    For jj = l To P - 1
    'Somme de volume
    Sheets("P_NA_HOD").Cells(jj, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "G"), Cells(DL_D, "G")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_HOD").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_HOD").Cells(jj, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_NA_HOD").Cells(jj, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "O"), Cells(DL_D, "O")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_HOD").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_HOD").Cells(jj, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_NA_HOD").Cells(jj, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "S"), Cells(DL_D, "S")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_HOD").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_HOD").Cells(jj, Col_Brand - 2))
    If Sheets("P_NA_HOD").Cells(j, Col_Brand - 2) = "Truck" Then
    'Somme de TKM truck
    Sheets("P_NA_HOD").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "P"), Cells(DL_D, "P")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_HOD").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_HOD").Cells(jj, Col_Brand - 2))
    Else
    If Sheets("P_NA_HOD").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_NA_HOD").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "Q"), Cells(DL_D, "Q")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_HOD").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_HOD").Cells(jj, Col_Brand - 2))
    Else
    If Sheets("P_NA_HOD").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_NA_HOD").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "R"), Cells(DL_D, "R")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_HOD").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_HOD").Cells(jj, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_NA_HOD").Cells(jj, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "T"), Cells(DL_D, "T")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_HOD").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_HOD").Cells(jj, Col_Brand - 2))
    Next jj
    '_________________________________________________________________________________________________________
    'Indirect"""""""""""""""
    ' DL_I et l'indice du la dernière non vide de la sheet"InDirect"'
    DL_I = 0
    Do While Not IsEmpty(Sheets("Indirect").Cells(DL_I + 1, 1))
    DL_I = DL_I + 1
    Loop
    Sheets("Indirect").Activate
    For jjj = P To q - 1
    'Somme de volume
    Sheets("P_NA_HOD").Cells(jjj, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "G"), Cells(DL_I, "G")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_NA_HOD").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_HOD").Cells(jjj, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_NA_HOD").Cells(jjj, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "O"), Cells(DL_I, "O")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_NA_HOD").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_HOD").Cells(jjj, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_NA_HOD").Cells(jjj, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "S"), Cells(DL_I, "S")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_NA_HOD").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_HOD").Cells(jjj, Col_Brand - 2))
    If Sheets("P_NA_HOD").Cells(j, Col_Brand - 2) = "Truck" Then
    'Somme de TKM truck
    Sheets("P_NA_HOD").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "P"), Cells(DL_I, "P")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_NA_HOD").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_HOD").Cells(jjj, Col_Brand - 2))
    Else
    If Sheets("P_NA_HOD").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_NA_HOD").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "Q"), Cells(DL_I, "Q")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_NA_HOD").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_HOD").Cells(jjj, Col_Brand - 2))
    Else
    If Sheets("P_NA_HOD").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_NA_HOD").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "R"), Cells(DL_I, "R")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_NA_HOD").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_HOD").Cells(jjj, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_NA_HOD").Cells(jjj, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "T"), Cells(DL_I, "T")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_NA_HOD").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_HOD").Cells(jjj, Col_Brand - 2))
    Next jjj
    End If
    If ActiveSheet.Name = "P_NA_IT" Then
    Sheets("Supply").Activate
    For j = Ligne_Brand + 3 To l - 1
    'Somme de volume
    Sheets("P_NA_IT").Cells(j, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "E"), Cells(DL_S, "E")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_IT").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_IT").Cells(j, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_NA_IT").Cells(j, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "L"), Cells(DL_S, "L")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_IT").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_IT").Cells(j, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_NA_IT").Cells(j, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "P"), Cells(DL_S, "P")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_IT").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_IT").Cells(j, Col_Brand - 2))
    If Sheets("P_NA_IT").Cells(j, Col_Brand - 2).Value = "Truck" Then
    'Somme de TKM truck
    Sheets("P_NA_IT").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "M"), Cells(DL_S, "M")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_IT").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_IT").Cells(j, Col_Brand - 2))
    Else
    If Sheets("P_NA_IT").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_NA_IT").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "N"), Cells(DL_S, "N")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_IT").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_IT").Cells(j, Col_Brand - 2))
    Else
    If Sheets("P_NA_IT").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_NA_IT").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "O"), Cells(DL_S, "O")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_IT").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_IT").Cells(j, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_NA_IT").Cells(j, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "Q"), Cells(DL_S, "Q")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_NA_IT").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_NA_IT").Cells(j, Col_Brand - 2))
    Next j
    '________________________________________________________________________________________________
    'Direct"""""""""""""""
    ' DL_D et l'indice du la dernière non vide de la sheet"Direct"'
    DL_D = 0
    Do While Not IsEmpty(Sheets("Direct").Cells(DL_D + 1, 1))
    DL_D = DL_D + 1
    Loop
    Sheets("Direct").Activate
    For jj = l To P - 1
    'Somme de volume
    Sheets("P_NA_IT").Cells(jj, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "G"), Cells(DL_D, "G")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_IT").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_IT").Cells(jj, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_NA_IT").Cells(jj, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "O"), Cells(DL_D, "O")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_IT").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_IT").Cells(jj, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_NA_IT").Cells(jj, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "S"), Cells(DL_D, "S")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_IT").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_IT").Cells(jj, Col_Brand - 2))
    If Sheets("P_NA_IT").Cells(j, Col_Brand - 2) = "Truck" Then
    'Somme de TKM truck
    Sheets("P_NA_IT").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "P"), Cells(DL_D, "P")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_IT").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_IT").Cells(jj, Col_Brand - 2))
    Else
    If Sheets("P_NA_IT").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_NA_IT").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "Q"), Cells(DL_D, "Q")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_IT").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_IT").Cells(jj, Col_Brand - 2))
    Else
    If Sheets("P_NA_IT").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_NA_IT").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "R"), Cells(DL_D, "R")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_IT").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_IT").Cells(jj, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_NA_IT").Cells(jj, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "T"), Cells(DL_D, "T")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_NA_IT").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_NA_IT").Cells(jj, Col_Brand - 2))
    Next jj
    '_________________________________________________________________________________________________________
    'Indirect"""""""""""""""
    ' DL_I et l'indice du la dernière non vide de la sheet"InDirect"'
    DL_I = 0
    Do While Not IsEmpty(Sheets("Indirect").Cells(DL_I + 1, 1))
    DL_I = DL_I + 1
    Loop
    Sheets("Indirect").Activate
    For jjj = P To q - 1
    'Somme de volume
    Sheets("P_NA_IT").Cells(jjj, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "G"), Cells(DL_I, "G")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_NA_IT").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_IT").Cells(jjj, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_NA_IT").Cells(jjj, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "O"), Cells(DL_I, "O")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_NA_IT").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_IT").Cells(jjj, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_NA_IT").Cells(jjj, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "S"), Cells(DL_I, "S")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_NA_IT").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_IT").Cells(jjj, Col_Brand - 2))
    If Sheets("P_NA_IT").Cells(j, Col_Brand - 2) = "Truck" Then
    'Somme de TKM truck
    Sheets("P_NA_IT").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "P"), Cells(DL_I, "P")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_NA_IT").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_IT").Cells(jjj, Col_Brand - 2))
    Else
    If Sheets("P_NA_IT").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_NA_IT").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "Q"), Cells(DL_I, "Q")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_NA_IT").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_IT").Cells(jjj, Col_Brand - 2))
    Else
    If Sheets("P_NA_IT").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_NA_IT").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "R"), Cells(DL_I, "R")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("PP_NA_IT").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_IT").Cells(jjj, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_NA_IT").Cells(jjj, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "T"), Cells(DL_I, "T")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_NA_IT").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_NA_IT").Cells(jjj, Col_Brand - 2))
    Next jjj
    End If
     
    If ActiveSheet.Name = "P_AOA_Retail" Then
    Sheets("Supply").Activate
    For j = Ligne_Brand + 3 To l - 1
    'Somme de volume
    Sheets("P_AOA_Retail").Cells(j, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "E"), Cells(DL_S, "E")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_AOA_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_AOA_Retail").Cells(j, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_AOA_Retail").Cells(j, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "L"), Cells(DL_S, "L")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_AOA_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_AOA_Retail").Cells(j, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_AOA_Retail").Cells(j, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "P"), Cells(DL_S, "P")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_AOA_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_AOA_Retail").Cells(j, Col_Brand - 2))
    If Sheets("P_AOA_Retail").Cells(j, Col_Brand - 2).Value = "Truck" Then
    'Somme de TKM truck
    Sheets("P_AOA_Retail").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "M"), Cells(DL_S, "M")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_AOA_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_AOA_Retail").Cells(j, Col_Brand - 2))
    Else
    If Sheets("P_AOA_Retail").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_AOA_Retail").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "N"), Cells(DL_S, "N")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_AOA_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_AOA_Retail").Cells(j, Col_Brand - 2))
    Else
    If Sheets("P_AOA_Retail").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_AOA_Retail").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "O"), Cells(DL_S, "O")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_AOA_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_AOA_Retail").Cells(j, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_AOA_Retail").Cells(j, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "Q"), Cells(DL_S, "Q")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_AOA_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_AOA_Retail").Cells(j, Col_Brand - 2))
     
     
    Next j
    '________________________________________________________________________________________________
    'Direct"""""""""""""""
    ' DL_D et l'indice du la dernière non vide de la sheet"Direct"'
    DL_D = 0
    Do While Not IsEmpty(Sheets("Direct").Cells(DL_D + 1, 1))
    DL_D = DL_D + 1
    Loop
    Sheets("Direct").Activate
    For jj = l To P - 1
    'Somme de volume
    Sheets("P_AOA_Retail").Cells(jj, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "G"), Cells(DL_D, "G")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_AOA_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_AOA_Retail").Cells(jj, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_AOA_Retail").Cells(jj, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "O"), Cells(DL_D, "O")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_AOA_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_AOA_Retail").Cells(jj, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_AOA_Retail").Cells(jj, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "S"), Cells(DL_D, "S")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_AOA_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_AOA_Retail").Cells(jj, Col_Brand - 2))
    If Sheets("P_AOA_Retail").Cells(j, Col_Brand - 2) = "Truck" Then
    'Somme de TKM truck
    Sheets("P_AOA_Retail").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "P"), Cells(DL_D, "P")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_AOA_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_AOA_Retail").Cells(jj, Col_Brand - 2))
    Else
    If Sheets("P_AOA_Retail").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_AOA_Retail").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "Q"), Cells(DL_D, "Q")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_AOA_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_AOA_Retail").Cells(jj, Col_Brand - 2))
    Else
    If Sheets("P_AOA_Retail").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_AOA_Retail").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "R"), Cells(DL_D, "R")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_AOA_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_AOA_Retail").Cells(jj, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_AOA_Retail").Cells(jj, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "T"), Cells(DL_D, "T")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_AOA_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_AOA_Retail").Cells(jj, Col_Brand - 2))
    Next jj
    '_________________________________________________________________________________________________________
    'Indirect"""""""""""""""
    ' DL_I et l'indice du la dernière non vide de la sheet"InDirect"'
    DL_I = 0
    Do While Not IsEmpty(Sheets("Indirect").Cells(DL_I + 1, 1))
    DL_I = DL_I + 1
    Loop
    Sheets("Indirect").Activate
    For jjj = P To q - 1
    'Somme de volume
    Sheets("P_AOA_Retail").Cells(jjj, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "G"), Cells(DL_I, "G")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_AOA_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_AOA_Retail").Cells(jjj, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_AOA_Retail").Cells(jjj, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "O"), Cells(DL_I, "O")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_AOA_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_AOA_Retail").Cells(jjj, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_AOA_Retail").Cells(jjj, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "S"), Cells(DL_I, "S")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_AOA_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_AOA_Retail").Cells(jjj, Col_Brand - 2))
    If Sheets("P_AOA_Retail").Cells(j, Col_Brand - 2) = "Truck" Then
    'Somme de TKM truck
    Sheets("P_AOA_Retail").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "P"), Cells(DL_I, "P")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_AOA_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_AOA_Retail").Cells(jjj, Col_Brand - 2))
    Else
    If Sheets("P_AOA_Retail").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_AOA_Retail").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "Q"), Cells(DL_I, "Q")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_AOA_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_AOA_Retail").Cells(jjj, Col_Brand - 2))
    Else
    If Sheets("P_AOA_Retail").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_AOA_Retail").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "R"), Cells(DL_I, "R")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_AOA_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_AOA_Retail").Cells(jjj, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_AOA_Retail").Cells(jjj, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "T"), Cells(DL_I, "T")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_AOA_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_AOA_Retail").Cells(jjj, Col_Brand - 2))
    Next jjj
    End If
     
    If ActiveSheet.Name = "P_AOA_HOD" Then
    Sheets("Supply").Activate
    For j = Ligne_Brand + 3 To l - 1
    'Somme de volume
    Sheets("P_AOA_HOD").Cells(j, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "E"), Cells(DL_S, "E")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_AOA_HOD").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_AOA_HOD").Cells(j, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_AOA_HOD").Cells(j, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "L"), Cells(DL_S, "L")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_AOA_HOD").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_AOA_HOD").Cells(j, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_AOA_HOD").Cells(j, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "P"), Cells(DL_S, "P")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_AOA_HOD").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_AOA_HOD").Cells(j, Col_Brand - 2))
    If Sheets("P_AOA_HOD").Cells(j, Col_Brand - 2).Value = "Truck" Then
    'Somme de TKM truck
    Sheets("P_AOA_HOD").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "M"), Cells(DL_S, "M")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_AOA_HOD").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_AOA_HOD").Cells(j, Col_Brand - 2))
    Else
    If Sheets("P_AOA_HOD").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_AOA_HOD").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "N"), Cells(DL_S, "N")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_AOA_HOD").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_AOA_HOD").Cells(j, Col_Brand - 2))
    Else
    If Sheets("P_AOA_HOD").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_AOA_HOD").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "O"), Cells(DL_S, "O")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_AOA_HOD").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_AOA_HOD").Cells(j, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_AOA_HOD").Cells(j, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "Q"), Cells(DL_S, "Q")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_AOA_HOD").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_AOA_HOD").Cells(j, Col_Brand - 2))
     
     
    Next j
    '________________________________________________________________________________________________
    'Direct"""""""""""""""
    ' DL_D et l'indice du la dernière non vide de la sheet"Direct"'
    DL_D = 0
    Do While Not IsEmpty(Sheets("Direct").Cells(DL_D + 1, 1))
    DL_D = DL_D + 1
    Loop
    Sheets("Direct").Activate
    For jj = l To P - 1
    'Somme de volume
    Sheets("P_AOA_HOD").Cells(jj, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "G"), Cells(DL_D, "G")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_AOA_HOD").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_AOA_HOD").Cells(jj, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_AOA_HOD").Cells(jj, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "O"), Cells(DL_D, "O")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_AOA_HOD").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_AOA_HOD").Cells(jj, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_AOA_HOD").Cells(jj, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "S"), Cells(DL_D, "S")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_AOA_HOD").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_AOA_HOD").Cells(jj, Col_Brand - 2))
    If Sheets("P_AOA_HOD").Cells(j, Col_Brand - 2) = "Truck" Then
    'Somme de TKM truck
    Sheets("P_AOA_HOD").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "P"), Cells(DL_D, "P")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_AOA_HOD").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_AOA_HOD").Cells(jj, Col_Brand - 2))
    Else
    If Sheets("P_AOA_HOD").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_AOA_HOD").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "Q"), Cells(DL_D, "Q")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_AOA_HOD").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_AOA_HOD").Cells(jj, Col_Brand - 2))
    Else
    If Sheets("P_AOA_HOD").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_AOA_HOD").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "R"), Cells(DL_D, "R")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_AOA_HOD").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_AOA_HOD").Cells(jj, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_AOA_HOD").Cells(jj, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "T"), Cells(DL_D, "T")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_AOA_HOD").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_AOA_HOD").Cells(jj, Col_Brand - 2))
    Next jj
    '_________________________________________________________________________________________________________
    'Indirect"""""""""""""""
    ' DL_I et l'indice du la dernière non vide de la sheet"InDirect"'
    DL_I = 0
    Do While Not IsEmpty(Sheets("Indirect").Cells(DL_I + 1, 1))
    DL_I = DL_I + 1
    Loop
    Sheets("Indirect").Activate
    For jjj = P To q - 1
    'Somme de volume
    Sheets("P_AOA_HOD").Cells(jjj, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "G"), Cells(DL_I, "G")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_AOA_HOD").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_AOA_HOD").Cells(jjj, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_AOA_HOD").Cells(jjj, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "O"), Cells(DL_I, "O")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_AOA_HOD").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_AOA_HOD").Cells(jjj, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_AOA_HOD").Cells(jjj, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "S"), Cells(DL_I, "S")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_AOA_HOD").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_AOA_HOD").Cells(jjj, Col_Brand - 2))
    If Sheets("P_AOA_HOD").Cells(j, Col_Brand - 2) = "Truck" Then
    'Somme de TKM truck
    Sheets("P_AOA_HOD").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "P"), Cells(DL_I, "P")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_AOA_HOD").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_AOA_HOD").Cells(jjj, Col_Brand - 2))
    Else
    If Sheets("P_AOA_HOD").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_AOA_HOD").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "Q"), Cells(DL_I, "Q")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_AOA_HOD").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_AOA_HOD").Cells(jjj, Col_Brand - 2))
    Else
    If Sheets("P_AOA_HOD").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_AOA_HOD").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "R"), Cells(DL_I, "R")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_AOA_HOD").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_AOA_HOD").Cells(jjj, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_AOA_HOD").Cells(jjj, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "T"), Cells(DL_I, "T")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_AOA_HOD").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_AOA_HOD").Cells(jjj, Col_Brand - 2))
    Next jjj
    End If
     
    If ActiveSheet.Name = "P_Latam_Retail" Then
    Sheets("Supply").Activate
    For j = Ligne_Brand + 3 To l - 1
    'Somme de volume
    Sheets("P_Latam_Retail").Cells(j, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "E"), Cells(DL_S, "E")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_Latam_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_Latam_Retail").Cells(j, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_Latam_Retail").Cells(j, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "L"), Cells(DL_S, "L")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_Latam_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_Latam_Retail").Cells(j, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_Latam_Retail").Cells(j, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "P"), Cells(DL_S, "P")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_Latam_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_Latam_Retail").Cells(j, Col_Brand - 2))
    If Sheets("P_Latam_Retail").Cells(j, Col_Brand - 2).Value = "Truck" Then
    'Somme de TKM truck
    Sheets("P_Latam_Retail").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "M"), Cells(DL_S, "M")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_Latam_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_Latam_Retail").Cells(j, Col_Brand - 2))
    Else
    If Sheets("P_Latam_Retail").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_Latam_Retail").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "N"), Cells(DL_S, "N")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_Latam_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_Latam_Retail").Cells(j, Col_Brand - 2))
    Else
    If Sheets("P_Latam_Retail").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_Latam_Retail").Cells(j, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "O"), Cells(DL_S, "O")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_Latam_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_Latam_Retail").Cells(j, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_Latam_Retail").Cells(j, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Supply").Range(Cells(2, "Q"), Cells(DL_S, "Q")), Sheets("Supply").Range(Cells(2, "B"), Cells(DL_S, "B")), Sheets("P_Latam_Retail").Cells(j, Col_Brand - 3), Sheets("Supply").Range(Cells(2, "F"), Cells(DL_S, "F")), Sheets("P_Latam_Retail").Cells(j, Col_Brand - 2))
     
     
    Next j
    '________________________________________________________________________________________________
    'Direct"""""""""""""""
    ' DL_D et l'indice du la dernière non vide de la sheet"Direct"'
    DL_D = 0
    Do While Not IsEmpty(Sheets("Direct").Cells(DL_D + 1, 1))
    DL_D = DL_D + 1
    Loop
    Sheets("Direct").Activate
    For jj = l To P - 1
    'Somme de volume
    Sheets("P_Latam_Retail").Cells(jj, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "G"), Cells(DL_D, "G")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_Latam_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_Latam_Retail").Cells(jj, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_Latam_Retail").Cells(jj, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "O"), Cells(DL_D, "O")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_Latam_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_Latam_Retail").Cells(jj, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_Latam_Retail").Cells(jj, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "S"), Cells(DL_D, "S")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_Latam_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_Latam_Retail").Cells(jj, Col_Brand - 2))
    If Sheets("P_Latam_Retail").Cells(j, Col_Brand - 2) = "Truck" Then
    'Somme de TKM truck
    Sheets("P_Latam_Retail").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "P"), Cells(DL_D, "P")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_Latam_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_Latam_Retail").Cells(jj, Col_Brand - 2))
    Else
    If Sheets("P_Latam_Retail").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_Latam_Retail").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "Q"), Cells(DL_D, "Q")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_Latam_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_Latam_Retail").Cells(jj, Col_Brand - 2))
    Else
    If Sheets("P_Latam_Retail").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_Latam_Retail").Cells(jj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "R"), Cells(DL_D, "R")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_Latam_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_Latam_Retail").Cells(jj, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_Latam_Retail").Cells(jj, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Direct").Range(Cells(2, "T"), Cells(DL_D, "T")), Sheets("Direct").Range(Cells(2, "B"), Cells(DL_D, "B")), Sheets("P_Latam_Retail").Cells(jj, Col_Brand - 3), Sheets("Direct").Range(Cells(2, "H"), Cells(DL_D, "H")), Sheets("P_Latam_Retail").Cells(jj, Col_Brand - 2))
    Next jj
    '_________________________________________________________________________________________________________
    'Indirect"""""""""""""""
    ' DL_I et l'indice du la dernière non vide de la sheet"InDirect"'
    DL_I = 0
    Do While Not IsEmpty(Sheets("Indirect").Cells(DL_I + 1, 1))
    DL_I = DL_I + 1
    Loop
    Sheets("Indirect").Activate
    For jjj = P To q - 1
    'Somme de volume
    Sheets("P_Latam_Retail").Cells(jjj, Col_Brand - 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "G"), Cells(DL_I, "G")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_Latam_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_Latam_Retail").Cells(jjj, Col_Brand - 2))
    'Somme de total liters
    Sheets("P_Latam_Retail").Cells(jjj, Col_Brand).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "O"), Cells(DL_I, "O")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_Latam_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_Latam_Retail").Cells(jjj, Col_Brand - 2))
    'somme de nombre de pallets
    Sheets("P_Latam_Retail").Cells(jjj, Col_Brand + 1).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "S"), Cells(DL_I, "S")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_Latam_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_Latam_Retail").Cells(jjj, Col_Brand - 2))
    If Sheets("P_Latam_Retail").Cells(j, Col_Brand - 2) = "Truck" Then
    'Somme de TKM truck
    Sheets("P_Latam_Retail").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "P"), Cells(DL_I, "P")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_Latam_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_Latam_Retail").Cells(jjj, Col_Brand - 2))
    Else
    If Sheets("P_Latam_Retail").Cells(j, Col_Brand - 2) = "Train" Then
    'Somme de TKM train
    Sheets("P_Latam_Retail").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "Q"), Cells(DL_I, "Q")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_Latam_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_Latam_Retail").Cells(jjj, Col_Brand - 2))
    Else
    If Sheets("P_Latam_Retail").Cells(j, Col_Brand - 2) = "Boat" Then
    'Somme de TKM boat
    Sheets("P_Latam_Retail").Cells(jjj, Col_Brand + 2).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "R"), Cells(DL_I, "R")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_Latam_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_Latam_Retail").Cells(jjj, Col_Brand - 2))
    End If
    End If
    End If
    'Somme de Gross weight
    Sheets("P_Latam_Retail").Cells(jjj, Col_Brand + 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Indirect").Range(Cells(2, "T"), Cells(DL_I, "T")), Sheets("Indirect").Range(Cells(2, "B"), Cells(DL_I, "B")), Sheets("P_Latam_Retail").Cells(jjj, Col_Brand - 3), Sheets("Indirect").Range(Cells(2, "H"), Cells(DL_I, "H")), Sheets("P_Latam_Retail").Cells(jjj, Col_Brand - 2))
    Next jjj
    End If
    End Sub

  4. #4
    Rédacteur/Modérateur

    Avatar de Jean-Philippe André
    Homme Profil pro
    Architecte Power Platform, ex-Développeur VBA/C#/VB.Net
    Inscrit en
    Juillet 2007
    Messages
    14 682
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : Canada

    Informations professionnelles :
    Activité : Architecte Power Platform, ex-Développeur VBA/C#/VB.Net
    Secteur : Finance

    Informations forums :
    Inscription : Juillet 2007
    Messages : 14 682
    Par défaut
    Salut,

    tu peux commencer par remplacer tes

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    If Sheets("p_EUROPE").Cells(j, Col_Brand - 2) = "Train" Then
    '...
    If Sheets("p_EUROPE").Cells(j, Col_Brand - 2) = "Boat" Then
    Par un Select Case
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    Select Case Sheets("p_EUROPE").Cells(j, Col_Brand - 2)
    Case "Train"
    Case "Boat"
    'etc.
    Cycle de vie d'un bon programme :
    1/ ça fonctionne 2/ ça s'optimise 3/ ça se refactorise

    Pas de question technique par MP, je ne réponds pas

    Mes ouvrages :
    Migrer les applications VBA Access et VBA Excel vers la Power Platform
    Apprendre à programmer avec Access 2016, Access 2019 et 2021

    Apprendre à programmer avec VBA Excel
    Prise en main de Dynamics 365 Business Central

    Coffrets disponibles de mes ouvrages : https://www.editions-eni.fr/jean-philippe-andre
    Pensez à consulter la FAQ Excel et la FAQ Access

    Derniers tutos
    Excel et les paramètres régionaux
    Les fichiers Excel binaires : xlsb,

    Autres tutos

  5. #5
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2017
    Messages
    23
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Mai 2017
    Messages : 23
    Par défaut
    J'ai utilisé le If car j'ai pas souvent les types de transport en méme temps "Train" Boat" et Truck"
    Je sais pas si Select Case peut marcher méme si y'a pas de "boat" par exemple ??

  6. #6
    Expert confirmé Avatar de BENNASR
    Homme Profil pro
    Responsable comptable & financier
    Inscrit en
    Décembre 2013
    Messages
    2 974
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Responsable comptable & financier
    Secteur : Finance

    Informations forums :
    Inscription : Décembre 2013
    Messages : 2 974
    Par défaut
    Bonjour
    Pour avoir de l'aide je crois que c'est utile d'afficher ton code et donner plus de détail de la structure et la taille de ton fichier

  7. #7
    Invité
    Invité(e)
    Par défaut
    en l’espèce, tu fais ce qu'on appel du code spaghetti!

    il faut que tu identifie le différentes action que ton code est censé faire!

    1. je fais ça
    2. puis ça
    3. puis ça
    4. puis etc...

    tu vas créer une méthode (Sub ou Function) pour chaque items {1 je fais ça}!

    après dans code tu appellera les méthodes en fonction des teste de condition!

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    SelectCase Sheets("p_EUROPE").Cells(j, Col_Brand - 2)Case "Train"
    Case "Boat" 'etc.

  8. #8
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2017
    Messages
    23
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Mai 2017
    Messages : 23
    Par défaut
    Merci dysorthographie , peux'tu me dire comment je peux découper mon code en des fonctions et puis faire un Call dans la procédure ?

  9. #9
    Membre Expert
    Femme Profil pro
    Ingénieur
    Inscrit en
    Octobre 2016
    Messages
    1 703
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 30
    Localisation : France, Indre et Loire (Centre)

    Informations professionnelles :
    Activité : Ingénieur
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2016
    Messages : 1 703
    Par défaut
    Bonjour,
    Une explication rapide : en programmation, il faut que tu découpes ce que tu veux faire en petites actions. Ensuite, tu apelles chaque action l'une après l'autre. Par exemple, tu veux faire les choses suivantes :
    • Si A1 = 1, alors A2 = OK, si A1 = 2, alors A2 = PEUT-ÊTRE, si A1 = 3, alors A2 = NON.
    • Si B1 = a, alors B2 = TOTO, si B1 = b, alors B2 = TITI, si B1 = c, alors A2 = TUTU.

    Tu pourrais écrire :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    Sub monProgramme()
        If Range("A1").Value = 1 Then 
            Range("A2").Value = "OK"
        ElseIf Range("A1").Value = 2 Then
            Range("A2").Value = "PEUT-ÊTRE"
        ElseIf Range("A1").Value = 3 Then
            Range("A2").Value = "NON"
        End If
     
        If Range("B1").Value = "a" Then 
            Range("B2").Value = "TOTO"
        ElseIf Range("B1").Value = "b" Then
            Range("B2").Value = "TITI"
        ElseIf Range("A1").Value = "c" Then
            Range("B2").Value = "TUTU"
        End If
    End Sub
    Mais ce que dysorthographie veut que tu écrives, c'est :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    Sub monProgramme()
        Call programmeA
        Call programmeB
    End Sub
     
    Sub programmeA()
        If Range("A1").Value = 1 Then 
            Range("A2").Value = "OK"
        ElseIf Range("A1").Value = 2 Then
            Range("A2").Value = "PEUT-ÊTRE"
        ElseIf Range("A1").Value = 3 Then
            Range("A2").Value = "NON"
        End If
    End Sub
     
    Sub programmeB()
        If Range("B1").Value = "a" Then 
            Range("B2").Value = "TOTO"
        ElseIf Range("B1").Value = "b" Then
            Range("B2").Value = "TITI"
        ElseIf Range("A1").Value = "c" Then
            Range("B2").Value = "TUTU"
        End If
    End Sub
    Bon, c'est pas un super exemple...mais c'est pour l'idée
    C'est mieux d'avoir des sous-programmes pour plusieurs raisons :
    • C'est plus rapide
    • C'est plus facile à débuguer, car c'est plus facile de vérifier un programme avec peu de lignes qu'un programme avec beaucoup de lignes. Et tu peux tester plus facilement un programme qui fait seulement quelques actions qu'un programme qui en fait une 10aine.
    • C'est plus facile d'utilisation : tu peux utiliser une même méthode plusieurs fois (éventuellement en utilisant des arguments) sans devoir tout ré-inventer à chaque fois.

    Il y a sûrement d'autres raisons ... mais c'est ce qui me vient là.

    EDIT : n'oublie pas aussi que tu peux utiliser les fonctions pour découper ton programme.

  10. #10
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2017
    Messages
    23
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Mai 2017
    Messages : 23
    Par défaut
    C'est très clair et utile Merci beaucoup

  11. #11
    Invité
    Invité(e)
    Par défaut
    Avant de ce lancer dans l'implémentation d'une macro, il faut lister le actions qui composeront le listing de notre code!

    Comme je suis un contemplatif, je fais la description de mes attentes!



    1. Nom du projet (Vélo)
      1. cadre
      2. roues
        1. pneus
        2. raillons
        3. moyeux
          1. roulement a billes
          2. etc...

      3. propulsion
        1. chêne
        2. pédalier

    ainsi je me retrouve avec une ossature de mon code avec de haut en bas les éléments de mon projet et de gauche à droite le détail de chaque élément!

    Par exemple mon projet gère plusieurs fichiers Excel !

    • Gestion des fichiers Excel
      • Gestion d’un fichier Excel
        • Gestion des onglets du fichier Excel
          • Gestion d’un des onglets du fichier Excel


    La on retrouve nos routines et nos sous routines !

  12. #12
    Membre Expert
    Profil pro
    Inscrit en
    Février 2007
    Messages
    2 266
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 2 266
    Par défaut
    Bonjour,

    et pour compléter quand tu fais une procédure qui fait une partie du boulot débogue-là complètement avant de passer à la suivante.
    Il en faut en être sûr à 100% et ne plus à avoir à revenir dessus, sinon tu ne sauras plus où donner de la tête si des erreurs peuvent survenir de n'importe où et à des occasions diverses.

    Et pense également que tu peux avoir des variables globales (déclarées au début hors procédure) qui seront visibles des toutes les procédures, et que tu peux également transmettre des paramètres à une proc si besoin.
    eric

Discussions similaires

  1. Procedure trop longue
    Par Frizz dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 14/09/2013, 09h12
  2. Erreur ORA-01704 : constante de chaine trop longue
    Par verrec_s dans le forum Oracle
    Réponses: 22
    Dernier message: 13/12/2004, 15h30
  3. [TP]Probleme de ligne trop longue
    Par poppels dans le forum Turbo Pascal
    Réponses: 4
    Dernier message: 24/09/2004, 06h36
  4. chaine trop longue pour envoyer en socket?
    Par jeje.r dans le forum C++Builder
    Réponses: 10
    Dernier message: 27/06/2003, 16h36

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo