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 :

Temps d'execution augmente à chaque réexecution


Sujet :

Macros et VBA Excel

  1. #1
    Candidat au Club
    Femme Profil pro
    Etudiante
    Inscrit en
    Mars 2021
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 25
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Etudiante

    Informations forums :
    Inscription : Mars 2021
    Messages : 5
    Points : 3
    Points
    3
    Par défaut Temps d'execution augmente à chaque réexecution
    Bonjour, je suis débutante en VBA, j'ai un projet avec des données confidenciels, et un fichier comporte plus de 10000 ligne de code,
    Mon code marche correctement, il y a pas d'erreur , mon seul soucis c'est que le temps d'excution ne fait qu'augementer a chaque fois que l'execute.
    La 1ere fois l'execution prenait 30sec, mais maintenant elle enmets 4 minutes , ca augmente de 10s a chaque fois des fois plus, et je ne comprends pas pourquoi
    Ma macro est accés lourde, donc j'ai ajouté ces deux lignes de codes au début de ma macro .

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    Application.ScreenUpdating = False
     
    Application.Calculation = xlCalculationManual
    et cela a la fin
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic
    Mais ca ne change rien, merci d'avance

  2. #2
    Expert confirmé Avatar de Patrice740
    Homme Profil pro
    Retraité
    Inscrit en
    Mars 2007
    Messages
    2 475
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 70
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Retraité
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Mars 2007
    Messages : 2 475
    Points : 5 630
    Points
    5 630
    Par défaut
    Bonjour,
    Citation Envoyé par Eyzii Voir le message
    Bonjour, je suis débutante en VBA, j'ai un projet ..... plus de 10000 ligne de code
    Pour une débutante, c'est qu'il comprend probablement 9900 lignes inutiles ....
    Mais si tu ne publies pas le code, impossible d'aider plus.
    Cordialement,
    Patrice
    Personne ne peut détenir tout le savoir, c'est pour ça qu'on le partage.

    Pour dire merci, cliquer sur et quand la discussion est finie, penser à cliquer sur

  3. #3
    Membre expérimenté Avatar de Transitoire
    Homme Profil pro
    Auditeur informatique
    Inscrit en
    Décembre 2017
    Messages
    724
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Auditeur informatique

    Informations forums :
    Inscription : Décembre 2017
    Messages : 724
    Points : 1 454
    Points
    1 454
    Par défaut
    Bonjour, êtes vous sure de ne pas confondre 10 000 lignes de code avec un tableau de 10 000 lignes?
    Il peut sembler impensable pour une débutante d'effectuer un code de 10 000 lignes, même avec l'enregistreur automatique de macros?
    quoi qu'il en soit cela manque cruellement de précisions et d'explications.
    Cordialement
    On a deux vies, la deuxième commence quand on se rend compte qu'on n'en a qu'une.
    Confucius

  4. #4
    Candidat au Club
    Femme Profil pro
    Etudiante
    Inscrit en
    Mars 2021
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 25
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Etudiante

    Informations forums :
    Inscription : Mars 2021
    Messages : 5
    Points : 3
    Points
    3
    Par défaut
    Citation Envoyé par Patrice740 Voir le message
    Bonjour,

    Pour une débutante, c'est qu'il comprend probablement 9900 lignes inutiles ....
    Mais si tu ne publies pas le code, impossible d'aider plus.
    Merci pour votre reponse, laissez moi vous expliquer.
    Je dois crée un planning ( comme un sorte de diagramme de gantt) comportent plusieurs projet chaque projet dispose de plusieurs dates de jalons etc.
    La partie planning comporte plusieurs calendriers (hebdomadaires) de 2019- 2026.
    Les données utilisée sont exporter de Sharepoint,
    et utilisé dans un tableau croisé dynamique
    L'utilisateur a l possibilité de cacher les calendriers ( en utilisant des macros qui permettent de masquer les colonnes, qui correspond ) sous format boutons.
    La macro est capable de calculer le numero de semaine d'une date X, la chercher dans la liste des calendriers puis precisé si c'est un J1 ou J2 ou 3 ... en fonction de la colonne d'ou la date a été recuperé.

    Mais aussi d'appliquer une couleur entre les differents jalons, en fonction du nom de la phase et de la couleur utilisé dans la legende.

    PS : Les dates des jalons sont dans des colonnes masqués, et vu qu'on peut pas effectuer de recherche dans des colonnes ou cellules cachées donc je suis obligé de reaffiché les valeurs cachée, et les recacher une fois que la macro est fini

    Je vous envoie ci-joint une capture d'ecran d'a quoi ressemble le planning, et le code de la macro

    PS: en cas de changement de données ou d'application de filtre sur la liste des projets, la macro s’exécute automatiquement, pour que le plan soit cohérent avant le projet
    et j 'ai caché les nom des responsables et projets pour des raisons de confidentialité


    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
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    892
    893
    894
    895
    896
    897
    898
    899
    900
    901
    902
    903
    904
    905
    906
    907
    908
    909
    910
    911
    912
    913
    914
    915
    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    927
    928
    929
    930
    931
    932
    933
    934
    935
    936
    937
    938
    939
    940
    941
    942
    943
    944
    945
    946
    947
    948
    949
    950
    951
    952
    953
    954
    955
    956
    957
    958
    959
    960
    961
    962
    963
    964
    965
    966
    967
    968
    969
    970
    971
    972
    973
    974
    975
    976
    977
    978
    979
    980
    981
    982
    983
    984
    985
    986
    987
    988
    989
    990
    991
    992
    993
    994
    995
    996
    997
    998
    999
    1000
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    1026
    1027
    1028
    1029
    1030
    1031
    1032
    1033
    1034
    1035
    1036
    1037
    1038
    1039
    1040
    1041
    1042
    1043
    1044
    1045
    1046
    1047
    1048
    1049
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    1057
    1058
    1059
    1060
    1061
    1062
    1063
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    1071
    1072
    1073
    1074
    1075
    1076
    1077
    1078
    1079
    1080
    1081
    1082
    1083
    1084
    1085
    1086
    1087
    1088
    1089
    1090
    1091
    1092
    1093
    1094
    1095
    1096
    1097
    1098
    1099
    1100
    1101
    1102
    1103
    1104
    1105
    1106
    1107
    1108
    1109
    1110
    1111
    1112
    1113
    1114
    1115
    1116
    1117
    1118
    1119
    1120
    1121
    1122
    1123
    1124
    1125
    1126
    1127
    1128
    1129
    1130
    1131
    1132
    1133
    1134
    1135
    1136
    1137
    1138
    1139
    1140
    1141
    1142
    1143
    1144
    1145
    1146
    1147
    1148
    1149
    1150
    1151
    1152
    1153
    1154
    1155
    1156
    1157
    1158
    1159
    1160
    1161
    1162
    1163
    1164
    1165
    1166
    1167
    1168
    1169
    1170
    1171
    1172
    1173
    1174
    1175
    1176
    1177
    1178
    1179
    1180
    1181
    1182
    1183
    1184
    1185
    1186
    1187
    1188
    1189
    1190
    1191
    1192
    1193
    1194
    1195
    1196
    1197
    1198
    1199
    1200
    1201
    1202
    1203
    1204
    1205
    1206
    1207
    1208
    1209
    1210
    1211
    1212
    1213
    1214
    1215
    1216
    1217
    1218
    1219
    1220
    1221
    1222
    1223
    1224
    1225
    1226
    1227
    1228
    1229
    1230
    1231
    1232
    1233
    1234
    1235
    1236
    1237
    1238
    1239
    1240
    1241
    1242
    1243
    1244
    1245
    1246
    1247
    1248
    1249
    1250
    1251
    1252
    1253
    1254
    1255
    1256
    1257
    1258
    1259
    1260
    1261
    1262
    1263
    1264
    1265
    1266
    1267
    1268
    1269
    1270
    1271
    1272
    1273
    1274
    1275
    1276
    1277
    1278
    1279
    1280
    1281
    1282
    1283
    1284
    1285
    1286
    1287
    1288
    1289
    1290
    1291
    1292
    1293
    1294
    1295
    1296
    1297
    1298
    1299
    1300
    1301
    1302
    1303
    1304
    1305
    1306
    1307
    1308
    1309
    1310
    1311
    1312
    1313
    1314
    1315
    1316
    1317
    1318
    1319
    1320
    1321
    1322
    1323
    1324
    1325
    1326
    1327
    1328
    1329
    1330
    1331
    1332
    1333
    1334
    1335
    1336
    1337
    1338
    1339
    1340
    1341
    1342
    1343
    1344
    1345
    1346
    1347
    1348
    1349
    1350
    1351
    1352
    1353
    1354
    1355
    1356
    1357
    1358
    '----------- Déclaration de variable----------------
    Public Const feuille As String = "PF-2i"
    Public Const cellMax  As Integer = 500
        Public Const cellMin As Integer = 1
      Public titre As Boolean, nbTitre As Integer, ligneCompt As Integer
            Public Jal As Date
            Public SemaineJal$, jalon$, mot$
            Public chercher, ligne As Range
            Public col, row, i, colTitre, colDate, rowDateJP, colDateJP, rowDateJR, colDateJR, rowDate, j, z, numcol, colCalender, colRetard As Integer
            Public colJSui, rowJSui As Integer
            Public retardJ As Integer
            Public ann19, ann20, ann21, ann22, ann23, ann24, ann25, ann26, curseur As Integer
    '-------------------- FIN DE DECLARATION ----------------------
     
     
     
     
        Sub CACHER()
        '
        ' CACHER Macro
        '
     
        '
     '      ---------------------------------------- TEST NON FINI -------------------------------------------------
    'Pour rendre cela plus robuste on va chercher la ou la colonne MP_P_Jal 0 existe faire acher les 16 colonneS qui suit
            'Dim i, row, col As Integer
             'i = 1
            'Do While (ligneCompt = 0)
     
           ' ce code permet de trouver la position de la colonne MP_P_Jal 0 dans  le tableau
     
           '     Set ligne = Worksheets(feuille).Rows(i).Find(What:="MP_P_Jal 0", LookIn:=xlValues, lookat:=xlWhole)
                   ' If Not ligne Is Nothing Then
                    'la ligne ou se trouve les libelles
                       ' row = ligne.row
     
                    '    col = ligne.Column
                 '   End If
                 '   i = i + 1
        '    Loop
     
     
     
     
            Columns("F:AH").Select
            Selection.EntireColumn.Hidden = True
        End Sub
        Sub Afficher()
        '
        ' Afficher les dates des jalons
        '
     
        '
     
            Columns("F:AH").Select
     
     
            Selection.EntireColumn.Hidden = False
            Range("B3").Select
     
        End Sub
        Sub ActualiserDymo1()
        '
        ' Actualiser Macro
        '
     
        '
        'Call actualiserexport
            Range("A10").Select
            ActiveSheet.PivotTables("Tableau croisé dynamique1").PivotCache.Refresh
        End Sub
     
     
     Sub RemplirPlan()
        '
        ' Remplir
        '
     
        '
     
    Dim MacroDebut As Date
     
            'stocker le moment de début
            MacroDebut = Now
     
          Application.ScreenUpdating = False
    'Application.EnableEvents = True
    Application.Calculation = xlCalculationManual
     
     
            'Dim titre As Boolean, nbTitre As Integer, ligneCompt As Integer
            'Dim Jal As Date
            'Dim SemaineJal$, jalon$, mot$
            'Dim chercher, ligne As Range
          '  Dim col, row, i, colTitre, colDate, rowDateJP, colDateJP, rowDateJR, colDateJR, rowDate, j, z, numcol, colCalender, colRetard As Integer
           ' Dim colJSui, rowJSui As Integer
           ' Dim retardJ As Integer
           ' Dim ann19, ann20, ann21, ann22, ann23, ann24, ann25, ann26, curseur As Integer
     
     
             titre = True
            i = 1
            Do While (ligneCompt = 0)
     
           ' ce code permet de trouver la position de la colonne titre dans  le tableau
     
                Set ligne = Worksheets(feuille).Range(Cells(i, 1), Cells(i, cellMax)).Find(What:="Titre", LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                    'la ligne ou se trouve les libelles
                        row = ligne.row
                        ' la ligne ou les projets commencent
                        ligneCompt = row + 1
                        'la ligne ou le planning reel sera dessiné
     
                        ligneComptP = row + 2
                        ' ??
                        curseur = row
                        ' Colonne ou les titres se trouve
                        colTitre = ligne.Column
                    End If
                    i = i + 1
            Loop
     
          '---------------pointer les calendriers ouverts des fermés ------------------------------
     
            'ce code permet de connaitre quel calendier etait ouvert et ainsi pouvoir actualiser sans devoir tout reouvrir
            i = 1
               numcol = 36
            Do While (colCalender = 0)
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="1 2019", LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colCalender = ligne.Column
                        rowCalender = ligne.row
                         Else
                         ann19 = 2
     
                         Range(Columns(numcol), Columns(numcol + 51)).Select
                         Selection.EntireColumn.Hidden = False
                    End If
                     Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="1 2020", LookIn:=xlValues, lookat:=xlWhole)
                    If ligne Is Nothing Then
                         ann20 = 2
     
                         Range(Columns(numcol + 52), Columns(numcol + 103)).Select
                         Selection.EntireColumn.Hidden = False
                    End If
                    Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="1 2021", LookIn:=xlValues, lookat:=xlWhole)
                    If ligne Is Nothing Then
     
                         ann21 = 2
     
                         Range(Columns(numcol + 104), Columns(numcol + 155)).Select
                         Selection.EntireColumn.Hidden = False
                    End If
                    Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="1 2022", LookIn:=xlValues, lookat:=xlWhole)
                    If ligne Is Nothing Then
     
                         ann22 = 2
     
                         Range(Columns(numcol + 156), Columns(numcol + 207)).Select
                         Selection.EntireColumn.Hidden = False
                    End If
                    Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="1 2023", LookIn:=xlValues, lookat:=xlWhole)
                    If ligne Is Nothing Then
     
                         ann23 = 2
     
                         Range(Columns(numcol + 208), Columns(numcol + 259)).Select
                         Selection.EntireColumn.Hidden = False
                    End If
                    Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="1 2024", LookIn:=xlValues, lookat:=xlWhole)
                    If ligne Is Nothing Then
     
                         ann24 = 2
     
                         Range(Columns(numcol + 260), Columns(numcol + 311)).Select
                         Selection.EntireColumn.Hidden = False
                    End If
                    Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="1 2025", LookIn:=xlValues, lookat:=xlWhole)
                    If ligne Is Nothing Then
     
                         ann25 = 2
     
                         Range(Columns(numcol + 312), Columns(numcol + 363)).Select
                         Selection.EntireColumn.Hidden = False
                    End If
     
                    Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="1 2026", LookIn:=xlValues, lookat:=xlWhole)
                    If ligne Is Nothing Then
     
                         ann26 = 2
                         Range(Columns(numcol + 364), Columns(numcol + 415)).Select
                         Selection.EntireColumn.Hidden = False
                    End If
     
                     Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="1 2027", LookIn:=xlValues, lookat:=xlWhole)
                    If ligne Is Nothing Then
     
                         ann27 = 2
                         Range(Columns(numcol + 416), Columns(numcol + 467)).Select
                         Selection.EntireColumn.Hidden = False
                    End If
     
                    ' Ajoutez le prochain calendrier au dessus de cette phrase
     
               i = i + 1
            Loop
                 '---------------FIN DU POINTAGE -----------------------------
     
     
           'nettoyage des cellules et les mise en page avant d'afficher la Macro
     
            Worksheets(feuille).Range(Cells(ligneCompt, colCalender), "AAA400").Clear
            Worksheets(feuille).Range(Cells(ligneCompt, colCalender - 1), Cells(4000, colCalender - 1)).ClearContents
     
     
     
     
             With Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax))
             Set ligne = .Find(What:="Retard", LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colRetard = ligne.Column
                    End If
                End With
                nbTitre = Application.WorksheetFunction.CountA(Columns(colTitre)) - 1
     
     
     
            Do While (titre = True)
            If (Not IsEmpty(Cells(ligneCompt, colTitre).Value)) Then
            'Recupration des dates de chaque jalons
                 i = 1
                 Dim variab$
                 variab = "MP_P_Jal 0"
                 curseur = colCalender
                 col = colCalender
               Call Afficher
     
                    Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                        If Not ligne Is Nothing Then
     
                            colDate = ligne.Column
                            If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                                Jal = Cells(ligneCompt, colDate).Value
                                If Jal <> 0 Then
                                    SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
     
                                    Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                                    If Not chercher Is Nothing Then
     
                                        col = chercher.Column
                                        Cells(ligneCompt, col) = "J0"
                                        With Cells(ligneCompt, col)
                                        .Font.ColorIndex = Cells(2, 4).Font.ColorIndex
                                        .Font.Bold = True
                                        .Interior.color = Cells(2, 4).Interior.color
                                        End With
     
                                        If (colCalender <> col) Then
                                            Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, colCalender)).Interior.color = RGB(255, 255, 255)
                                            End If
     
                                        Jal = 0
                                        SemaineJal = 0
     
                                    End If
     
                                End If
                            End If
     
                            Else
                        Range(Cells(row, 1), Cells(row, cellMax)).Select
                        MsgBox " c est tjr vide " & row
                   End If
     
     
     
                'J1
     
                  variab = "MP_P_Jal 1 (A)"
     
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
                        If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                            Jal = Cells(ligneCompt, colDate).Value
                            If Jal <> 0 Then
     
                                SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                                Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                                curseur = col
                                If Not chercher Is Nothing Then
                                 col = chercher.Column
                                 Cells(ligneCompt, col) = "J1"
                                 With Cells(ligneCompt, col)
                                 .Font.ColorIndex = 1
                                  .Font.Bold = True
                                  End With
                                  If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur)).Interior.color = Cells(3, 4).Interior.color
                                     End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur + 1)).Interior.color = Cells(3, 4).Interior.color
                                  End If
     
                                 Jal = 0
                                 SemaineJal = 0
                             End If
                          End If
                        End If
                    End If
     
     
     
     
     
               'J2_1
     
     
                  variab = "MP_P_Jal 2.1 (B)"
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
                         If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                            Jal = Cells(ligneCompt, colDate).Value
                            If Jal <> 0 Then
                            curseur = col
                            SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                            Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                            If Not chercher Is Nothing Then
                               col = chercher.Column
                                Cells(ligneCompt, col) = "J2_1"
                               With Cells(ligneCompt, col)
                               .Font.ColorIndex = 1
                                .Font.Bold = True
                                End With
                                If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur)).Interior.color = Cells(4, 4).Interior.color
                                    End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur + 1)).Interior.color = Cells(4, 4).Interior.color
                                  End If
     
                                Jal = 0
                                SemaineJal = 0
                        End If
                    End If
                End If
                    End If
     
             'macroEtap6 = Now
     
     
                'J2_2
     
                  variab = "MP_P_Jal 2.2 (B1)"
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
                             If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                    Jal = Cells(ligneCompt, colDate).Value
                    If Jal <> 0 Then
                    curseur = col
                        SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                        Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                        If Not chercher Is Nothing Then
                            col = chercher.Column
                             Cells(ligneCompt, col) = "J2_2"
                             With Cells(ligneCompt, col)
                            .Font.ColorIndex = 1
                             .Font.Bold = True
                             End With
                             If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur)).Interior.color = Cells(5, 4).Interior.color
                                  End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur + 1)).Interior.color = Cells(5, 4).Interior.color
                                  End If
     
                            Jal = 0
                            SemaineJal = 0
                        End If
                    End If
                End If
     
     
                    End If
     
     
     
               'J2_3
     
                  variab = "MP_P_Jal 2.3 (B2)"
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
                         If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                    Jal = Cells(ligneCompt, colDate).Value
                    If Jal <> 0 Then
                    curseur = col
                        SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                        Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                        If Not chercher Is Nothing Then
                            col = chercher.Column
                            Cells(ligneCompt, col) = "J2_3"
                          With Cells(ligneCompt, col)
                          .Font.ColorIndex = 1
                            .Font.Bold = True
                            End With
     
                            If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur)).Interior.color = Cells(6, 4).Interior.color
                                     End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur + 1)).Interior.color = Cells(6, 4).Interior.color
                                  End If
                            j = 0
                            Jal = 0
                            SemaineJal = 0
                        End If
                    End If
                End If
     
                    End If
     
     
     
     
                  variab = "MP_P_Jal3 (C)"
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
                       If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                            Jal = Cells(ligneCompt, colDate).Value
                            If Jal <> 0 Then
                            curseur = col
                                SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                                Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                                If Not chercher Is Nothing Then
                                   col = chercher.Column
                                   Cells(ligneCompt, col) = "J3"
                                   With Cells(ligneCompt, col)
                                   .Font.ColorIndex = 1
                                   .Font.Bold = True
                                   End With
     
                                  If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur)).Interior.color = Cells(7, 4).Interior.color
                                  End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur + 1)).Interior.color = Cells(7, 4).Interior.color
                                  End If
                                    j = 0
                                    Jal = 0
                                    SemaineJal = 0
                                End If
                            End If
                        End If
                   End If
     
     
     
     
                  variab = "MP_P_Jal 4"
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
     
                      If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                    Jal = Cells(ligneCompt, colDate).Value
                    If Jal <> 0 Then
                    curseur = col
                        SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                        Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                        If Not chercher Is Nothing Then
                            col = chercher.Column
                            Cells(ligneCompt, col) = "J4"
                            With Cells(ligneCompt, col)
                            Cells(ligneCompt, col).Font.ColorIndex = 1
                             Cells(ligneCompt, col).Font.Bold = True
                             End With
     
                             If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur)).Interior.color = Cells(8, 4).Interior.color
                                     End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur + 1)).Interior.color = Cells(8, 4).Interior.color
     
                                  End If
     
                            Jal = 0
                            SemaineJal = 0
                        End If
                    End If
                End If
                    End If
     
     
     
     
                  variab = "MP_P_Jal 5"
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
     
                         If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                    Jal = Cells(ligneCompt, colDate).Value
                    If Jal <> 0 Then
                    curseur = col
                        SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                        Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                        If Not chercher Is Nothing Then
                            col = chercher.Column
                            Cells(ligneCompt, col) = "J5"
                            With Cells(ligneCompt, col)
                           .Font.ColorIndex = 1
                            .Font.Bold = True
                        End With
                             If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur)).Interior.color = Cells(9, 4).Interior.color
                                    End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur + 1)).Interior.color = Cells(9, 4).Interior.color
                                  End If
                            Jal = 0
                            SemaineJal = 0
                        End If
                    End If
                End If
                    End If
     
     
     
     
                  variab = "MP_P_Jal 6"
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
                          If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                    Jal = Cells(ligneCompt, colDate).Value
                    If Jal <> 0 Then
                    curseur = col
                        SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                        Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                        If Not chercher Is Nothing Then
                            col = chercher.Column
     
                            Cells(ligneCompt, col) = "J6"
                            With Cells(ligneCompt, col)
                           .Font.ColorIndex = 1
                            .Font.Bold = True
                        End With
                             If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur)).Interior.color = Cells(10, 4).Interior.color
                                    End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur + 1)).Interior.color = Cells(10, 4).Interior.color
                                  End If
                            Jal = 0
                            SemaineJal = 0
                        End If
                    End If
                 End If
     
                    End If
     
     
     
     
                  variab = "MP_P_Jal 7 (D)"
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
                        If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                    Jal = Cells(ligneCompt, colDate).Value
                    If Jal <> 0 Then
                    curseur = col
                        SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                        Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                        If Not chercher Is Nothing Then
                            col = chercher.Column
                            Cells(ligneCompt, col) = "J7"
                             With Cells(ligneCompt, col)
                           .Font.ColorIndex = 1
                            .Font.Bold = True
                        End With
                             If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur)).Interior.color = Cells(11, 4).Interior.color
                                    End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur + 1)).Interior.color = Cells(11, 4).Interior.color
                                  End If
                            Jal = 0
                            SemaineJal = 0
                        End If
                    End If
                 End If
     
     
                    End If
     
     
     
                  variab = "MP_P_Jal 8 (E)"
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
     
                If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                    Jal = Cells(ligneCompt, colDate).Value
                    If Jal <> 0 Then
                     curseur = col
                        SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                        Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                        If Not chercher Is Nothing Then
                       col = chercher.Column
                       Cells(ligneCompt, col) = "J8"
                        With Cells(ligneCompt, col)
                           .Font.ColorIndex = 1
                            .Font.Bold = True
                        End With
                             If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur)).Interior.color = Cells(12, 4).Interior.color
                                  End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur + 1)).Interior.color = Cells(12, 4).Interior.color
                                  End If
                        Jal = 0
                        SemaineJal = 0
                           End If
                        End If
                     End If
                    End If
     
     
        Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="J suivant", LookIn:=xlValues, lookat:=xlWhole)
            If Not ligne Is Nothing Then
            'recuperer sa position
                colJSui = ligne.Column
                rowJSui = ligne.row
            End If
            retardJ = 0
           Do While (retardJ = 0)
              If (Cells(ligneCompt, colJSui) = "Jalon J0") Then
                 Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_P_Jal 0", LookIn:=xlValues, lookat:=xlWhole)
                        If Not ligne Is Nothing Then
                            colDateJP = ligne.Column
                        End If
                    Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_R_Jal 0", LookIn:=xlValues, lookat:=xlWhole)
                       If Not ligne Is Nothing Then
                            colDateJR = ligne.Column
                            If ((Cells(ligneCompt, colDateJP) < Cells(ligneCompt, colDateJR)) And Cells(ligneCompt, colDateJR) <> "(vide)") Then
                            retardJ = DateDiff("d", Cells(ligneCompt, colDateJR), Cells(ligneCompt, colDateJP))
     
                        Else
                            If (Cells(ligneCompt, colDateJP).Value < Date) Then
                            retardJ = DateDiff("d", Date, Cells(ligneCompt, colDateJP))
                            End If
                        End If
                        End If
     
                    End If
     
     
                        If (Cells(ligneCompt, colJSui) = "Jalon J1") Then
                             Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_P_Jal 1 (A)", LookIn:=xlValues, lookat:=xlWhole)
                                If Not ligne Is Nothing Then
                                    colDateJP = ligne.Column
                                End If
                           Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_R_Jal 1 (A)", LookIn:=xlValues, lookat:=xlWhole)
                                   If Not ligne Is Nothing Then
                                  colDateJR = ligne.Column
                                  If (Cells(ligneCompt, colDateJP) < Cells(ligneCompt, colDateJR) And Cells(ligneCompt, colDateJR) <> "(vide)") Then
                                  retardJ = DateDiff("d", Cells(ligneCompt, colDateJR), Cells(ligneCompt, colDateJP))
     
                              Else
                                  If (Cells(ligneCompt, colDateJP) < Date) Then
                                  retardJ = DateDiff("d", Date, Cells(ligneCompt, colDateJP))
                                  End If
                              End If
            End If
                          End If
     
                          If (Cells(ligneCompt, colJSui) = "Jalon J2.1") Then
                             Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_P_Jal 2.1 (B)", LookIn:=xlValues, lookat:=xlWhole)
                                If Not ligne Is Nothing Then
                                    colDateJP = ligne.Column
                                End If
                            Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_R_Jal 2.1 (B)", LookIn:=xlValues, lookat:=xlWhole)
                                If Not ligne Is Nothing Then
                            colDateJR = ligne.Column
                            If (Cells(ligneCompt, colDateJP) < Cells(ligneCompt, colDateJR) And Cells(ligneCompt, colDateJR) <> "(vide)") Then
                            retardJ = DateDiff("d", Cells(ligneCompt, colDateJR), Cells(ligneCompt, colDateJP))
     
                        Else
                            If (Cells(ligneCompt, colDateJP) < Date) Then
                            retardJ = DateDiff("d", Date, Cells(ligneCompt, colDateJP))
                            End If
                        End If
            End If
                    End If
     
                        If (Cells(ligneCompt, colJSui) = "Jalon J2.2") Then
                             Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_P_Jal 2.2 (B1)", LookIn:=xlValues, lookat:=xlWhole)
                                If Not ligne Is Nothing Then
                                    colDateJP = ligne.Column
                                End If
                           Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_R_Jal 2.2 (B1)", LookIn:=xlValues, lookat:=xlWhole)
                             If Not ligne Is Nothing Then
                            colDateJR = ligne.Column
                            If (Cells(ligneCompt, colDateJP) < Cells(ligneCompt, colDateJR) And Cells(ligneCompt, colDateJR) <> "(vide)") Then
                            retardJ = DateDiff("d", Cells(ligneCompt, colDateJR), Cells(ligneCompt, colDateJP))
     
                        Else
                            If (Cells(ligneCompt, colDateJP) < Date) Then
                            retardJ = DateDiff("d", Date, Cells(ligneCompt, colDateJP))
                            End If
                        End If
          End If
                    End If
     
     
                    If (Cells(ligneCompt, colJSui) = "Jalon J2.3") Then
                             Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_P_Jal 2.3 (B2)", LookIn:=xlValues, lookat:=xlWhole)
                                If Not ligne Is Nothing Then
                                    colDateJP = ligne.Column
                                End If
                          Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_R_Jal 2.3 (B2)", LookIn:=xlValues, lookat:=xlWhole)
                            If Not ligne Is Nothing Then
                            colDateJR = ligne.Column
                            If (Cells(ligneCompt, colDateJP) < Cells(ligneCompt, colDateJR) And Cells(ligneCompt, colDateJR) <> "(vide)") Then
                            retardJ = DateDiff("d", Cells(ligneCompt, colDateJR), Cells(ligneCompt, colDateJP))
     
                        Else
                            If (Cells(ligneCompt, colDateJP) < Date) Then
                            retardJ = DateDiff("d", Date, Cells(ligneCompt, colDateJP))
                            End If
                        End If
       End If
                    End If
     
                    If (Cells(ligneCompt, colJSui) = "Jalon J3") Then
                             Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_P_Jal 3 (C)", LookIn:=xlValues, lookat:=xlWhole)
                                If Not ligne Is Nothing Then
                                    colDateJP = ligne.Column
                                End If
                           Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_R_Jal 3 (C)", LookIn:=xlValues, lookat:=xlWhole)
                           If Not ligne Is Nothing Then
                            colDateJR = ligne.Column
                            If (Cells(ligneCompt, colDateJP) < Cells(ligneCompt, colDateJR) And Cells(ligneCompt, colDateJR) <> "(vide)") Then
                            retardJ = DateDiff("d", Cells(ligneCompt, colDateJR), Cells(ligneCompt, colDateJP))
     
                        Else
                            If (Cells(ligneCompt, colDateJP) < Date) Then
                            retardJ = DateDiff("d", Date, Cells(ligneCompt, colDateJP))
                            End If
                        End If
         End If
                    End If
     
                    If (Cells(ligneCompt, colJSui) = "Jalon J4") Then
                             Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_P_Jal 4", LookIn:=xlValues, lookat:=xlWhole)
                                If Not ligne Is Nothing Then
                                    colDateJP = ligne.Column
                                End If
                           Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_R_Jal 4", LookIn:=xlValues, lookat:=xlWhole)
                             If Not ligne Is Nothing Then
                            colDateJR = ligne.Column
                            If (Cells(ligneCompt, colDateJP) < Cells(ligneCompt, colDateJR) And Cells(ligneCompt, colDateJR) <> "(vide)") Then
                            retardJ = DateDiff("d", Cells(ligneCompt, colDateJR), Cells(ligneCompt, colDateJP))
     
                        Else
                            If (Cells(ligneCompt, colDateJP) < Date) Then
                            retardJ = DateDiff("d", Date, Cells(ligneCompt, colDateJP))
                            End If
                        End If
           End If
                    End If
     
                    If (Cells(ligneCompt, colJSui) = "Jalon J5") Then
                             Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_P_Jal 5", LookIn:=xlValues, lookat:=xlWhole)
                                If Not ligne Is Nothing Then
                                    colDateJP = ligne.Column
                                End If
                           Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_R_Jal 5", LookIn:=xlValues, lookat:=xlWhole)
                                 If Not ligne Is Nothing Then
                                      colDateJR = ligne.Column
                                      If (Cells(ligneCompt, colDateJP) < Cells(ligneCompt, colDateJR) And Cells(ligneCompt, colDateJR) <> "(vide)") Then
                                      retardJ = DateDiff("d", Cells(ligneCompt, colDateJR), Cells(ligneCompt, colDateJP))
                                      End If
                                  Else
                                      If (Cells(ligneCompt, colDateJP) < Date) Then
                                      retardJ = DateDiff("d", Date, Cells(ligneCompt, colDateJP))
                                      End If
                                  End If
     
                              End If
     
                    If (Cells(ligneCompt, colJSui) = "Jalon J6") Then
                             Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_P_Jal 6", LookIn:=xlValues, lookat:=xlWhole)
                                If Not ligne Is Nothing Then
                                    colDateJP = ligne.Column
                                End If
                            Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_R_Jal 6", LookIn:=xlValues, lookat:=xlWhole)
                             If Not ligne Is Nothing Then
                            colDateJR = ligne.Column
                            If (Cells(ligneCompt, colDateJP) < Cells(ligneCompt, colDateJR) And Cells(ligneCompt, colDateJR) <> "(vide)") Then
                            retardJ = DateDiff("d", Cells(ligneCompt, colDateJR), Cells(ligneCompt, colDateJP))
     
                        Else
                            If (Cells(ligneCompt, colDateJP) < Date) Then
                            retardJ = DateDiff("d", Date, Cells(ligneCompt, colDateJP))
                            End If
                        End If
      End If
                    End If
     
                    If (Cells(ligneCompt, colJSui) = "Jalon J7") Then
                             Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_P_Jal 7 (D)", LookIn:=xlValues, lookat:=xlWhole)
                                If Not ligne Is Nothing Then
                                    colDateJP = ligne.Column
                                End If
                            Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_R_Jal 7 (D)", LookIn:=xlValues, lookat:=xlWhole)
                                   If Not ligne Is Nothing Then
                                      colDateJR = ligne.Column
                                      If (Cells(ligneCompt, colDateJP) < Cells(ligneCompt, colDateJR) And Cells(ligneCompt, colDateJR) <> "(vide)") Then
                                      retardJ = DateDiff("d", Cells(ligneCompt, colDateJR), Cells(ligneCompt, colDateJP))
     
                                  Else
                                      If (Cells(ligneCompt, colDateJP) < Date) Then
                                      retardJ = DateDiff("d", Date, Cells(ligneCompt, colDateJP))
                                      End If
                                  End If
                   End If
                              End If
     
     
                    If (Cells(ligneCompt, colJSui) = "Jalon J8") Then
                             Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_P_Jal 8 (E)", LookIn:=xlValues, lookat:=xlWhole)
                                If Not ligne Is Nothing Then
                                    colDateJP = ligne.Column
                                End If
                            Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:="MP_R_Jal 8 (E)", LookIn:=xlValues, lookat:=xlWhole)
                           If Not ligne Is Nothing Then
                            colDateJR = ligne.Column
                            If (Cells(ligneCompt, colDateJP) < Cells(ligneCompt, colDateJR) And Cells(ligneCompt, colDateJR) <> "(vide)") Then
                            retardJ = DateDiff("d", Cells(ligneCompt, colDateJR), Cells(ligneCompt, colDateJP))
     
                        Else
                            If (Cells(ligneCompt, colDateJP) < Date) Then
                            retardJ = DateDiff("d", Date, Cells(ligneCompt, colDateJP))
                            End If
                        End If
       End If
                    End If
     
                    Cells(ligneCompt, colRetard) = retardJ
                    retardJ = 1
                Loop
     
                   ' End If
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
                  variab = "MP_R_Jal 0"
     
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
     
                      If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                    Jal = Cells(ligneCompt, colDate).Value
                    If Jal <> 0 Then
     
                        SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                        Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                        If Not chercher Is Nothing Then
     
                            col = chercher.Column
                            Cells(ligneComptP, col) = "J0"
                            With Cells(ligneComptP, col)
                            .Font.ColorIndex = Cells(2, 5).Font.ColorIndex
                            .Font.Bold = True
                            .Interior.color = Cells(2, 5).Interior.color
                            End With
                            If (colCalender <> col) Then
                            Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, colCalender)).Interior.color = RGB(255, 255, 255)
                            End If
     
                            Jal = 0
                            SemaineJal = 0
     
                        End If
                    End If
                End If
     
                    End If
     
     
     
                'J1
     
                  variab = "MP_R_Jal 1 (A)"
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
                     If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                    Jal = Cells(ligneCompt, colDate).Value
                    If Jal <> 0 Then
                        curseur = col
                        SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                        Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                        If Not chercher Is Nothing Then
                         col = chercher.Column
                         Cells(ligneComptP, col) = "J1"
                         With Cells(ligneComptP, col)
                         .Font.ColorIndex = 1
                          .Font.Bold = True
                          End With
                         If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                  Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, curseur)).Interior.color = Cells(3, 5).Interior.color
                       End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                                  Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, curseur + 1)).Interior.color = Cells(3, 5).Interior.color
                                  End If
                                     If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur)).Interior.color = Cells(3, 4).Interior.color
                                     End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                                  Range(Cells(ligneCompt, col - 1), Cells(ligneCompt, curseur + 1)).Interior.color = Cells(3, 4).Interior.color
                                  End If
                         Jal = 0
                         SemaineJal = 0
                     End If
                  End If
                End If
     
                    End If
     
     
     
     
               'J2_1
     
                  variab = "MP_R_Jal 2.1 (B)"
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
                             If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                    Jal = Cells(ligneCompt, colDate).Value
                    If Jal <> 0 Then
                    curseur = col
                        SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                        Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                        If Not chercher Is Nothing Then
                           col = chercher.Column
                           Cells(ligneComptP, col) = "J2_1"
                             With Cells(ligneComptP, col)
                         .Font.ColorIndex = 1
                          .Font.Bold = True
                          End With
                         If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                  Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, curseur)).Interior.color = Cells(4, 5).Interior.color
                         End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                                  Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, curseur + 1)).Interior.color = Cells(4, 5).Interior.color
                                  End If
                            Jal = 0
                            SemaineJal = 0
                        End If
                    End If
                End If
     
                    End If
     
     
     
                'J2_2
     
                  variab = "MP_R_Jal 2.2 (B1)"
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
                        If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                    Jal = Cells(ligneCompt, colDate).Value
                    If Jal <> 0 Then
                    curseur = col
                        SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                        Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                        If Not chercher Is Nothing Then
                            col = chercher.Column
                            Cells(ligneComptP, col) = "J2_2"
                               With Cells(ligneComptP, col)
                                .Font.ColorIndex = 1
                                 .Font.Bold = True
                                 End With
                             If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                      Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, curseur)).Interior.color = Cells(5, 5).Interior.color
                             End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                            Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, curseur + 1)).Interior.color = Cells(5, 5).Interior.color
                            End If
                            Jal = 0
                            SemaineJal = 0
                        End If
                    End If
                End If
     
                    End If
     
     
     
     
               'J2_3
     
                  variab = "MP_R_Jal 2.3 (B2)"
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
                         If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                    Jal = Cells(ligneCompt, colDate).Value
                    If Jal <> 0 Then
                    curseur = col
                        SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                        Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                        If Not chercher Is Nothing Then
                            col = chercher.Column
                           Cells(ligneComptP, col) = "J2_3"
                            With Cells(ligneComptP, col)
                         .Font.ColorIndex = 1
                          .Font.Bold = True
                          End With
                         If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                  Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, curseur)).Interior.color = Cells(6, 5).Interior.color
                         End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                                  Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, curseur + 1)).Interior.color = Cells(6, 5).Interior.color
                                  End If
                            Jal = 0
                            SemaineJal = 0
                        End If
                    End If
                End If
     
                    End If
     
     
     
     
                  variab = "MP_R_Jal 3 (C)"
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
     
                If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                    Jal = Cells(ligneCompt, colDate).Value
                    If Jal <> 0 Then
                    curseur = col
                        SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                        Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                        If Not chercher Is Nothing Then
                           col = chercher.Column
                           Cells(ligneComptP, col) = "J3"
                         With Cells(ligneComptP, col)
                         .Font.ColorIndex = 1
                          .Font.Bold = True
                          End With
                         If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                  Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, curseur)).Interior.color = Cells(7, 5).Interior.color
                         End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                                  Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, curseur + 1)).Interior.color = Cells(7, 5).Interior.color
                                  End If
                            Jal = 0
                            SemaineJal = 0
                        End If
                    End If
                End If
     
                    End If
     
     
     
                  variab = "MP_R_Jal 4"
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
     
     
                If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                    Jal = Cells(ligneCompt, colDate).Value
                    If Jal <> 0 Then
                    curseur = col
                        SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                        Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                        If Not chercher Is Nothing Then
                            col = chercher.Column
                            Cells(ligneComptP, col) = "J4"
                             With Cells(ligneComptP, col)
                         .Font.ColorIndex = 1
                          .Font.Bold = True
                          End With
                         If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                  Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, curseur)).Interior.color = Cells(8, 5).Interior.color
                         End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                                  Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, curseur + 1)).Interior.color = Cells(8, 5).Interior.color
                                  End If
                            Jal = 0
                            SemaineJal = 0
                        End If
                    End If
                End If
                    End If
     
     
     
                  variab = "MP_R_Jal 5"
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
                       If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                    Jal = Cells(ligneCompt, colDate).Value
                    If Jal <> 0 Then
                    curseur = col
                        SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                        Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                        If Not chercher Is Nothing Then
                            col = chercher.Column
                           Cells(ligneComptP, col) = "J5"
                               With Cells(ligneComptP, col)
                         .Font.ColorIndex = 1
                          .Font.Bold = True
                          End With
                         If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                  Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, curseur)).Interior.color = Cells(9, 5).Interior.color
                         End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                                  Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, curseur + 1)).Interior.color = Cells(9, 5).Interior.color
                                  End If
                            Jal = 0
                            SemaineJal = 0
                        End If
                    End If
                End If
     
                    End If
     
     
     
     
                  variab = "MP_R_Jal 6"
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
                         If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                    Jal = Cells(ligneCompt, colDate).Value
                    If Jal <> 0 Then
                    curseur = col
                        SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                        Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                        If Not chercher Is Nothing Then
                            col = chercher.Column
                            Cells(ligneComptP, col) = "J6"
                         With Cells(ligneComptP, col)
                         .Font.ColorIndex = 1
                          .Font.Bold = True
                          End With
                         If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                  Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, curseur)).Interior.color = Cells(10, 5).Interior.color
                         End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                                  Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, curseur + 1)).Interior.color = Cells(10, 5).Interior.color
                                  End If
                            Jal = 0
                            SemaineJal = 0
                        End If
                    End If
                 End If
     
                    End If
     
     
     
     
                  variab = "MP_R_Jal 7 (D)"
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
     
                      If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                    Jal = Cells(ligneCompt, colDate).Value
                    If Jal <> 0 Then
                    curseur = col
                        SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                        Set chercher = Worksheets(feuille).Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                        If Not chercher Is Nothing Then
                            col = chercher.Column
                            Cells(ligneComptP, col) = "J7"
                            With Cells(ligneComptP, col)
                         .Font.ColorIndex = 1
                          .Font.Bold = True
                          End With
                         If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                  Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, curseur)).Interior.color = Cells(11, 5).Interior.color
                         End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                                  Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, curseur + 1)).Interior.color = Cells(11, 5).Interior.color
                                  End If
                            Jal = 0
                            SemaineJal = 0
                        End If
                    End If
                 End If
                    End If
     
     
     
     
                  variab = "MP_R_Jal 8 (E)"
     
                Set ligne = Worksheets(feuille).Range(Cells(row, 1), Cells(row, cellMax)).Find(What:=variab, LookIn:=xlValues, lookat:=xlWhole)
                    If Not ligne Is Nothing Then
                        colDate = ligne.Column
     
                            If (Cells(ligneCompt, colDate).Value <> "(vide)") Then
                    Jal = Cells(ligneComp, colDate).Value
                    If Jal <> 0 Then
                    curseur = col
                        SemaineJal = DatePart("ww", Jal) & " " & year(Jal)
                        Set chercher = Worksheets(feuille).Match("SelectedEvent").Range(Cells(rowCalender, 1), Cells(rowCalender, cellMax)).Find(What:=SemaineJal, LookIn:=xlValues, lookat:=xlWhole)
                        If Not chercher Is Nothing Then
                       col = chercher.Column
                       Cells(ligneComptP, col) = "J8"
                          With Cells(ligneComptP, col)
                         .Font.ColorIndex = 1
                          .Font.Bold = True
                          End With
                         If (curseur = colCalender And Cells(ligneCompt, curseur).Value = "") Then
                                  Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, curseur)).Interior.color = Cells(12, 5).Interior.color
                         End If
                                   If (Cells(ligneCompt, col - 1) = "") Then
                                  Range(Cells(ligneComptP, col - 1), Cells(ligneComptP, curseur + 1)).Interior.color = Cells(12, 5).Interior.color
                                  End If
                        Jal = 0
                        SemaineJal = 0
     
                      End If
                        End If
                     End If
     
                    End If
                        'Rows(ligneComptP).Select
                        'Range(Cells(ligneComptP, 1), Cells(ligneComptP, 488)).Select
                        With Range(Cells(ligneComptP, 1), Cells(ligneComptP, 800)).Borders(xlEdgeBottom)
                            .LineStyle = xlContinuous
                            .ColorIndex = xlAutomatic
                            .TintAndShade = 0
                            .Weight = xlThick
                        End With
     
                Else
                ligneCompt = ligneCompt + 1
                If (IsEmpty(Cells(ligneCompt, colTitre).Value)) Then
                titre = False
                End If
     
           End If
     
            ligneCompt = ligneCompt + 2
            ligneComptP = ligneComptP + 2
     
          Jal = 0
          SemaineJal = 0
     
           Loop
              Call CACHER
     
               numcol = 36
     
               If (ann19 = 2) Then
                         Range(Columns(numcol), Columns(numcol + 51)).Select
                         Selection.EntireColumn.Hidden = True
               End If
     
                If (ann20 = 2) Then
                         Range(Columns(numcol + 52), Columns(numcol + 103)).Select
                         Selection.EntireColumn.Hidden = True
               End If
     
                If (ann21 = 2) Then
                         Range(Columns(numcol + 104), Columns(numcol + 155)).Select
                         Selection.EntireColumn.Hidden = True
               End If
     
                If (ann22 = 2) Then
                         Range(Columns(numcol + 156), Columns(numcol + 207)).Select
                         Selection.EntireColumn.Hidden = True
               End If
     
                If (ann23 = 2) Then
                         Range(Columns(numcol + 208), Columns(numcol + 259)).Select
                         Selection.EntireColumn.Hidden = True
               End If
     
                If (ann24 = 2) Then
                         Range(Columns(numcol + 260), Columns(numcol + 311)).Select
                         Selection.EntireColumn.Hidden = True
               End If
     
                If (ann25 = 2) Then
                         Range(Columns(numcol + 312), Columns(numcol + 363)).Select
                         Selection.EntireColumn.Hidden = True
               End If
     
                If (ann26 = 2) Then
                         Range(Columns(numcol + 364), Columns(numcol + 415)).Select
                         Selection.EntireColumn.Hidden = True
               End If
             Range("B6").Select
           Application.ScreenUpdating = True
        Application.Calculation = xlCalculationAutomatic
           MsgBox "Durée d'exécution: " & Format(Now - MacroDebut, "hh:mm:ss")
     
     
        End Sub
    Images attachées Images attachées  

  5. #5
    Expert confirmé Avatar de Patrice740
    Homme Profil pro
    Retraité
    Inscrit en
    Mars 2007
    Messages
    2 475
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 70
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Retraité
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Mars 2007
    Messages : 2 475
    Points : 5 630
    Points
    5 630
    Par défaut
    Re,

    Ce code est totalement imbuvable, il faut tout reprendre :
    - une routine de devrait pas faire plus de 50 à 100 lignes et doit être compréhensible par tout le monde.
    - On ne répète pas de nombreuses fois des bloc d'instructions similaires, il faut créer des sous-routines dédiées.
    - Il y a beaucoup trop de variables inutiles, au lieu d'utiliser une variable A, puis B, puis C, puis ... on peut souvent se contenter de A
    - Il ne faut pas déclarer toutes les variables publiques : il faut limiter la portée des variables au strict minimum utile
    - Il faut typer chaque variable, pas uniquement la dernière de la ligne de déclaration.
    - Il ne faut jamais utiliser Select, ni Selection, sauf dans les 0,00% des cas où c'est indispensable : c'est extrêmement chronophage et source de nombreuses erreurs.
    - .....
    Cordialement,
    Patrice
    Personne ne peut détenir tout le savoir, c'est pour ça qu'on le partage.

    Pour dire merci, cliquer sur et quand la discussion est finie, penser à cliquer sur

  6. #6
    Candidat au Club
    Femme Profil pro
    Etudiante
    Inscrit en
    Mars 2021
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 25
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Etudiante

    Informations forums :
    Inscription : Mars 2021
    Messages : 5
    Points : 3
    Points
    3
    Par défaut
    J’ai essayé de faire ca, sauf ce n’est pas possible, on peut pas effectuer de recherche dans des colonnes ou lignes cachées, j’ai essayé de créer des boucles pour ne pas devoir répéter le code 8 fois a chaque fois. Sauf que les valeurs recherchées ne sont pas les memes, et je ne sais pas si je peux appliquer une boucle sur une variable, et pour les variables c’est pas qu ils sont inutiles, mais c est surtout parceque chaque variable correspond a un changement , ces valeurs doivent être conservées pour les exploiter apres.
    Par exemple les variables ann19,ann20.... est ce qu il y a moyen de faire une boucle de 19 a 26 et que ca s’applique sur «*ann»& i
    Comment pouvais je éviter cette répétition

  7. #7
    Candidat au Club
    Femme Profil pro
    Etudiante
    Inscrit en
    Mars 2021
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 25
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Etudiante

    Informations forums :
    Inscription : Mars 2021
    Messages : 5
    Points : 3
    Points
    3
    Par défaut
    Citation Envoyé par Patrice740 Voir le message
    Re,

    Ce code est totalement imbuvable, il faut tout reprendre :
    - une routine de devrait pas faire plus de 50 à 100 lignes et doit être compréhensible par tout le monde.
    - On ne répète pas de nombreuses fois des bloc d'instructions similaires, il faut créer des sous-routines dédiées.
    - Il y a beaucoup trop de variables inutiles, au lieu d'utiliser une variable A, puis B, puis C, puis ... on peut souvent se contenter de A
    - Il ne faut pas déclarer toutes les variables publiques : il faut limiter la portée des variables au strict minimum utile
    - Il faut typer chaque variable, pas uniquement la dernière de la ligne de déclaration.
    - Il ne faut jamais utiliser Select, ni Selection, sauf dans les 0,00% des cas où c'est indispensable : c'est extrêmement chronophage et source de nombreuses erreurs.
    - .....

    Rebonjour,
    J'ai pris en considération vos remarques et j'ai essqyé de suivre vos conseils comme je peux.
    Le code a été reduit et le resultat est comme ceci
    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
     
    Option Explicit
     
    '----------- Déclaration de variable----------------
    Public Const feuille As String = "PF-2i"
    Public Const feuil As String = "PF-Pratiq"
    Public Const cellMax  As Integer = 500
        Public Const cellMin As Integer = 1
     
     
     
    Sub creePlan()
     
     
            'stocker le moment de début
            Dim MacroDebut As Date
            MacroDebut = Now
            Dim titre As Boolean, nbTitre%, plan_Planifier%
            Dim Jal As Date, SemaineJal$
            Dim chercher As Range, valeurCherchee As Range, numAnnee As Range, titreCherchee As Range, pointAnnee As Range, retardCherchee As Range
            Dim col%, ligne_des_Libelles%, i%, colTitre%, colDate%, nomColAnnee%, j%, z%, numColonne%, colonne%, colRetard As Integer, colJSuivant As Range
            Dim colJSui%, rowJSui%, retardJ%, curseur%, anneeCal%, variab$, yearJal%, colDateJP%, colDateJR%
            Dim tabJalons(3, 13) As String
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
             titre = True
     
             ' ------------------- Remplir le tableau des libelles de jalons ---------------
             tabJalons(0, 0) = "MP_P_Jal 0"
             tabJalons(0, 1) = "MP_P_Jal 1 (A)"
             tabJalons(0, 2) = "MP_P_Jal 2.1 (B)"
             tabJalons(0, 3) = "MP_P_Jal 2.2 (B1)"
             tabJalons(0, 4) = "MP_P_Jal 2.3 (B2)"
             tabJalons(0, 5) = "MP_P_Jal 3 (C)"
             tabJalons(0, 6) = "MP_P_Jal 4"
             tabJalons(0, 7) = "MP_P_Jal 5"
             tabJalons(0, 8) = "MP_P_Jal 6"
             tabJalons(0, 9) = "MP_P_Jal 7 (D)"
             tabJalons(0, 10) = "MP_P_Jal 8 (E)"
     
             tabJalons(1, 0) = "MP_R_Jal 0"
             tabJalons(1, 1) = "MP_R_Jal 1 (A)"
             tabJalons(1, 2) = "MP_R_Jal 2.1 (B)"
             tabJalons(1, 3) = "MP_R_Jal 2.2 (B1)"
             tabJalons(1, 4) = "MP_R_Jal 2.3 (B2)"
             tabJalons(1, 5) = "MP_R_Jal 3 (C)"
             tabJalons(1, 6) = "MP_R_Jal 4"
             tabJalons(1, 7) = "MP_R_Jal 5"
             tabJalons(1, 8) = "MP_R_Jal 6"
             tabJalons(1, 9) = "MP_R_Jal 7 (D)"
             tabJalons(1, 10) = "MP_R_Jal 8 (E)"
     
             tabJalons(2, 0) = "J0"
             tabJalons(2, 1) = "J1"
             tabJalons(2, 2) = "J2.1"
             tabJalons(2, 3) = "J2.2"
             tabJalons(2, 4) = "J2.3"
             tabJalons(2, 5) = "J3"
             tabJalons(2, 6) = "J4"
             tabJalons(2, 7) = "J5"
             tabJalons(2, 8) = "J6"
             tabJalons(2, 9) = "J7"
             tabJalons(2, 10) = "J8"
     
              tabJalons(3, 0) = "Jalon J0"
             tabJalons(3, 1) = "Jalon J1"
             tabJalons(3, 2) = "Jalon J2.1"
             tabJalons(3, 3) = "Jalon J2.2"
             tabJalons(3, 4) = "Jalon J2.3"
             tabJalons(3, 5) = "Jalon J3"
             tabJalons(3, 6) = "Jalon J4"
             tabJalons(3, 7) = "Jalon J5"
             tabJalons(3, 8) = "Jalon J6"
             tabJalons(3, 9) = "Jalon J7"
             tabJalons(3, 10) = "Jalon J8"
            i = 1
            Do While (plan_Planifier = 0)
           ' ce code permet de trouver la position de la colonne titre dans  le tableau
                Set titreCherchee = Worksheets(feuil).Columns(i).Find(What:="Titre", LookIn:=xlFormulas, LookAt:=xlWhole)
                    If Not titreCherchee Is Nothing Then
                    'la ligne ou se trouve les libelles
                        ligne_des_Libelles = titreCherchee.row
                        ' la ligne ou les projets commencent
                        plan_Planifier = ligne_des_Libelles + 1
                        'la ligne ou le planning reel sera dessiné
                        plan_Reel = ligne_des_Libelles + 2
                        curseur = ligne_des_Libelles
                        ' Colonne ou les titres se trouve
                        colTitre = titreCherchee.Column
     
                    End If
                    i = i + 1
            Loop
     
               i = 1
               j = 0
     
               anneeCal = 2019
                Do While (numColonne = 0)
                Set pointAnnee = Worksheets(feuil).Columns(i).Find(What:=anneeCal, LookIn:=xlFormulas, LookAt:=xlWhole)
                    ' une fois trouver on va attribuer le numero de colonne et numero de ligne du mot rechercher au variable colonne et ligne
                          If Not pointAnnee Is Nothing Then
                            numColonne = pointAnnee.Column - 4
                            nomColAnnee = pointAnnee.Column
                            End If
                           i = i + 1
                Loop
        'nettoyage des cellules et les mise en page avant d'afficher la Macro
     
            Worksheets(feuil).Range(Cells(plan_Planifier, numColonne), "BAA4000").Clear
            Worksheets(feuil).Range(Cells(plan_Planifier, numColonne - 1), Cells(4000, numColonne - 1)).ClearContents
     
            ' Trouver la colonne retard
            i = 1
     
            Do While (colRetard = 0)
                 Set retardCherchee = Worksheets(feuil).Columns(i).Find(What:="Retard", LookIn:=xlFormulas, LookAt:=xlWhole)
                If (Not retardCherchee Is Nothing) Then
                 colRetard = retardCherchee.Column
                End If
                 Set colJSuivant = Worksheets(feuil).Columns(i).Find(What:="J suivant", LookIn:=xlFormulas, LookAt:=xlWhole)
                    If Not colJSuivant Is Nothing Then
                        colJSui = colJSuivant.Column
                        rowJSui = colJSuivant.row
                    End If
                                   i = i + 1
                    Loop
                       nbTitre = Application.WorksheetFunction.CountA(Columns(colTitre)) - 1
     
           Set colJSuivant = Nothing
            retardJ = 0
     
                 Do While (titre = True)
                         If (Not IsEmpty(Cells(plan_Planifier, colTitre).Value)) Then
                           'Recupration des dates de chaque jalons
                                z = nomColAnnee
                                curseur = numColonne
                                 col = numColonne
                                For i = 0 To 1
                                        For j = 0 To 10
                                                variab = tabJalons(i, j)
                                                Set valeurCherchee = Worksheets(feuil).Range(Cells(ligne_des_Libelles, 1), Cells(ligne_des_Libelles, cellMax)).Find(What:=variab, LookIn:=xlFormulas, LookAt:=xlWhole)
                                                If Not valeurCherchee Is Nothing Then
                                                    colDate = valeurCherchee.Column
                                                    If (Cells(plan_Planifier, colDate).Value <> "(vide)") Then
                                                        Jal = Cells(plan_Planifier, colDate).Value
                                                        If Jal <> 0 Then
                                                            SemaineJal = DatePart("ww", Jal)
                                                            yearJal = year(Jal)
                                                            'chercher le calendrier concerné
                                                              Do While (colonne = 0 And yearJal >= 2019 And yearJal <= 2028)
                                                                Set numAnnee = Worksheets(feuil).Columns(z).Find(What:=yearJal, LookIn:=xlFormulas, LookAt:=xlWhole)
                                                                ' une fois trouver on va attribuer le numero de colonne et numero de ligne du mot rechercher au variable colonne et ligne
                                                                    If Not numAnnee Is Nothing Then
                                                                       colonne = numAnnee.Column - 4
                                                                       'chercher la semaine dans la plage du calendrier dédié
                                                                       Set chercher = Worksheets(feuil).Range(Cells(ligne_des_Libelles, colonne), Cells(ligne_des_Libelles, colonne + 51)).Find(What:=SemaineJal, LookIn:=xlFormulas, LookAt:=xlWhole)
                                                                       curseur = col
                                                                         If Not chercher Is Nothing Then
                                                                          col = chercher.Column
                                                                             If (i = 0) Then
                                                                                   If (Cells(plan_Planifier, col) <> "J0") Then
                                                                                        Cells(plan_Planifier, col) = tabJalons(2, j)
                                                                                        With Cells(plan_Planifier, col)
                                                                                                    .Font.ColorIndex = 1
                                                                                                     .Font.Bold = True
                                                                                        End With
                                                                                    End If
                                                                                 Select Case tabJalons(2, j)
                                                                                    Case "J0"
                                                                                        With Cells(plan_Planifier, col)
                                                                                        .Font.ColorIndex = Cells(i + 2, i + 4).Font.ColorIndex
                                                                                        .Font.Bold = True
                                                                                        .Interior.color = Cells(i + 2, i + 4).Interior.color
                                                                                        End With
                                                                                         If (numColonne <> col) Then
                                                                                            Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, numColonne)).Interior.color = Cells(i + 1, i + 4).Interior.color
                                                                                        End If
                                                                                        Case "J1"
                                                                                             If (curseur = numColonne And Cells(plan_Planifier, curseur).Value = "") Then
                                                                                             Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, curseur)).Interior.color = Cells(i + 3, i + 4).Interior.color
                                                                                                End If
                                                                                              If (Cells(plan_Planifier, col - 1) = "") Then
                                                                                             Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, curseur + 1)).Interior.color = Cells(3, 4).Interior.color
                                                                                             End If
                                                                                    Case "J2.1"
                                                                                             If (curseur = numColonne And Cells(plan_Planifier, curseur).Value = "") Then
                                                                                               Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, curseur)).Interior.color = Cells(4, 4).Interior.color
                                                                                                 End If
                                                                                                If (Cells(plan_Planifier, col - 1) = "") Then
                                                                                                Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, curseur + 1)).Interior.color = Cells(4, 4).Interior.color
                                                                                               End If
                                                                                 Case "J2.2"
                                                                                             If (curseur = numColonne And Cells(plan_Planifier, curseur).Value = "") Then
                                                                                               Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, curseur)).Interior.color = Cells(5, 4).Interior.color
                                                                                                 End If
                                                                                                If (Cells(plan_Planifier, col - 1) = "") Then
                                                                                                Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, curseur + 1)).Interior.color = Cells(5, 4).Interior.color
                                                                                               End If
                                                                                 Case "J2.3"
                                                                                             If (curseur = numColonne And Cells(plan_Planifier, curseur).Value = "") Then
                                                                                               Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, curseur)).Interior.color = Cells(6, 4).Interior.color
                                                                                                 End If
                                                                                                If (Cells(plan_Planifier, col - 1) = "") Then
                                                                                                Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, curseur + 1)).Interior.color = Cells(6, 4).Interior.color
                                                                                               End If
                                                                                 Case "J3"
                                                                                             If (curseur = numColonne And Cells(plan_Planifier, curseur).Value = "") Then
                                                                                               Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, curseur)).Interior.color = Cells(7, 4).Interior.color
                                                                                                 End If
                                                                                                If (Cells(plan_Planifier, col - 1) = "") Then
                                                                                                Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, curseur + 1)).Interior.color = Cells(7, 4).Interior.color
                                                                                               End If
                                                                                 Case "J4"
                                                                                             If (curseur = numColonne And Cells(plan_Planifier, curseur).Value = "") Then
                                                                                               Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, curseur)).Interior.color = Cells(8, 4).Interior.color
                                                                                                 End If
                                                                                                If (Cells(plan_Planifier, col - 1) = "") Then
                                                                                                Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, curseur + 1)).Interior.color = Cells(8, 4).Interior.color
                                                                                               End If
                                                                                Case "J5"
                                                                                             If (curseur = numColonne And Cells(plan_Planifier, curseur).Value = "") Then
                                                                                               Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, curseur)).Interior.color = Cells(9, 4).Interior.color
                                                                                                 End If
                                                                                                If (Cells(plan_Planifier, col - 1) = "") Then
                                                                                                Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, curseur + 1)).Interior.color = Cells(9, 4).Interior.color
                                                                                               End If
                                                                                Case "J6"
                                                                                               If (curseur = numColonne And Cells(plan_Planifier, curseur).Value = "") Then
                                                                                               Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, curseur)).Interior.color = Cells(10, 4).Interior.color
                                                                                                 End If
                                                                                                If (Cells(plan_Planifier, col - 1) = "") Then
                                                                                                Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, curseur + 1)).Interior.color = Cells(10, 4).Interior.color
                                                                                               End If
                                                                                Case "J7"
                                                                                             If (curseur = numColonne And Cells(plan_Planifier, curseur).Value = "") Then
                                                                                               Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, curseur)).Interior.color = Cells(11, 4).Interior.color
                                                                                                 End If
                                                                                                If (Cells(plan_Planifier, col - 1) = "") Then
                                                                                                Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, curseur + 1)).Interior.color = Cells(11, 4).Interior.color
                                                                                               End If
                                                                                Case "J8"
                                                                                            If (curseur = numColonne And Cells(plan_Planifier, curseur).Value = "") Then
                                                                                               Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, curseur)).Interior.color = Cells(12, 4).Interior.color
                                                                                                End If
                                                                                                If (Cells(plan_Planifier, col - 1) = "") Then
                                                                                                Range(Cells(plan_Planifier, col - 1), Cells(plan_Planifier, curseur + 1)).Interior.color = Cells(12, 4).Interior.color
                                                                                               End If
                                                                                End Select
                                                                            Else
                                                                                 Cells(plan_Planifier + 1, col) = tabJalons(2, j)
     
                                                                                 If (Cells(plan_Planifier + 1, col) <> "J0") Then
                                                                                        With Cells(plan_Planifier + 1, col)
                                                                                            .Font.ColorIndex = Cells(i + 2, i + 5).Font.ColorIndex
                                                                                            .Font.Bold = True
                                                                                            .Interior.color = Cells(i + 2, i + 5).Interior.color
                                                                                        End With
                                                                                    End If
                                                                                  Select Case tabJalons(2, j)
                                                                                    Case "J0"
                                                                                        With Cells(plan_Planifier + 1, col)
                                                                                              .Font.ColorIndex = Cells(2, 5).Font.ColorIndex
                                                                                              .Font.Bold = True
                                                                                              .Interior.color = Cells(2, 5).Interior.color
                                                                                        End With
                                                                                            If (numColonne <> col) Then
                                                                                              Range(Cells(plan_Planifier + 1, col - 1), Cells(plan_Planifier + 1, numColonne)).Interior.color = Cells(1, 5).Interior.color
                                                                                          End If
                                                                                        Case "J1"
                                                                                             If (curseur = numColonne And Cells(plan_Planifier + 1, curseur).Value = "") Then
                                                                                             Range(Cells(plan_Planifier + 1, col - 1), Cells(plan_Planifier + 1, curseur)).Interior.color = Cells(2, 5).Interior.color
                                                                                            End If
                                                                                              If (Cells(plan_Planifier + 1, col - 1) = "") Then
                                                                                             Range(Cells(plan_Planifier + 1, col - 1), Cells(plan_Planifier + 1, curseur + 1)).Interior.color = Cells(3, 5).Interior.color
                                                                                             End If
                                                                                    Case "J2.1"
                                                                                             If (curseur = numColonne And Cells(plan_Planifier + 1, curseur).Value = "") Then
                                                                                               Range(Cells(plan_Planifier + 1, col - 1), Cells(plan_Planifier + 1, curseur)).Interior.color = Cells(4, 5).Interior.color
                                                                                                 End If
                                                                                                If (Cells(plan_Planifier + 1, col - 1) = "") Then
                                                                                                Range(Cells(plan_Planifier + 1, col - 1), Cells(plan_Planifier + 1, curseur + 1)).Interior.color = Cells(4, 5).Interior.color
                                                                                               End If
                                                                                 Case "J2.2"
                                                                                             If (curseur = numColonne And Cells(plan_Planifier + 1, curseur).Value = "") Then
                                                                                               Range(Cells(plan_Planifier + 1, col - 1), Cells(plan_Planifier + 1, curseur)).Interior.color = Cells(5, 5).Interior.color
                                                                                                 End If
                                                                                                If (Cells(plan_Planifier + 1, col - 1) = "") Then
                                                                                                Range(Cells(plan_Planifier + 1, col - 1), Cells(plan_Planifier + 1, curseur + 1)).Interior.color = Cells(5, 5).Interior.color
                                                                                               End If
                                                                                Case "J2.3"
                                                                                             If (curseur = numColonne And Cells(plan_Planifier + 1, curseur).Value = "") Then
                                                                                               Range(Cells(plan_Planifier + 1, col - 1), Cells(plan_Planifier + 1, curseur)).Interior.color = Cells(6, 5).Interior.color
                                                                                                 End If
                                                                                                If (Cells(plan_Planifier + 1, col - 1) = "") Then
                                                                                                Range(Cells(plan_Planifier + 1, col - 1), Cells(plan_Planifier + 1, curseur + 1)).Interior.color = Cells(6, 5).Interior.color
                                                                                               End If
                                                                                Case "J3"
                                                                                             If (curseur = numColonne And Cells(plan_Planifier + 1, curseur).Value = "") Then
                                                                                               Range(Cells(plan_Planifier + 1, col - 1), Cells(plan_Planifier + 1, curseur)).Interior.color = Cells(7, 5).Interior.color
                                                                                                 End If
                                                                                                If (Cells(plan_Planifier + 1, col - 1) = "") Then
                                                                                                Range(Cells(plan_Planifier + 1, col - 1), Cells(plan_Planifier + 1, curseur + 1)).Interior.color = Cells(7, 5).Interior.color
                                                                                               End If
                                                                                Case "J4"
                                                                                             If (curseur = numColonne And Cells(plan_Planifier + 1, curseur).Value = "") Then
                                                                                               Range(Cells(plan_Planifier + 1, col - 1), Cells(plan_Planifier + 1, curseur)).Interior.color = Cells(8, 5).Interior.color
                                                                                                 End If
                                                                                                If (Cells(plan_Planifier + 1, col - 1) = "") Then
                                                                                                Range(Cells(plan_Planifier + 1, col - 1), Cells(plan_Planifier + 1, curseur + 1)).Interior.color = Cells(8, 5).Interior.color
                                                                                               End If
                                                                                   Case "J5"
                                                                                             If (curseur = numColonne And Cells(plan_Planifier + 1, curseur).Value = "") Then
                                                                                               Range(Cells(plan_Planifier + 1, col - 1), Cells(plan_Planifier + 1, curseur)).Interior.color = Cells(9, 5).Interior.color
                                                                                                 End If
                                                                                                If (Cells(plan_Planifier + 1, col - 1) = "") Then
                                                                                                Range(Cells(plan_Planifier + 1, col - 1), Cells(plan_Planifier + 1, curseur + 1)).Interior.color = Cells(9, 5).Interior.color
                                                                                               End If
                                                                                        Case "J6"
                                                                                             If (curseur = numColonne And Cells(plan_Planifier + 1, curseur).Value = "") Then
                                                                                               Range(Cells(plan_Planifier + 1, col - 1), Cells(plan_Planifier + 1, curseur)).Interior.color = Cells(10, 5).Interior.color
                                                                                                 End If
                                                                                                If (Cells(plan_Planifier + 1, col - 1) = "") Then
                                                                                                Range(Cells(plan_Planifier + 1, col - 1), Cells(plan_Planifier + 1, curseur + 1)).Interior.color = Cells(10, 5).Interior.color
                                                                                               End If
                                                                                End Select
                                                                            End If
                                                                            If (Cells(plan_Planifier, colJSui) = tabJalons(3, j)) Then
                                                                               Set colJSuivant = Worksheets(feuil).Range(Cells(ligne_des_Libelles, 1), Cells(ligne_des_Libelles, cellMax)).Find(What:=tabJalons(0, j), LookIn:=xlFormulas, LookAt:=xlWhole)
                                                                                      If Not colJSuivant Is Nothing Then
                                                                                          colDateJP = colJSuivant.Column
                                                                                      End If
                                                                                  Set colJSuivant = Worksheets(feuil).Range(Cells(ligne_des_Libelles, 1), Cells(ligne_des_Libelles, cellMax)).Find(What:=tabJalons(1, j), LookIn:=xlFormulas, LookAt:=xlWhole)
                                                                                     If Not colJSuivant Is Nothing Then
                                                                                          colDateJR = colJSuivant.Column
                                                                                          If ((Cells(plan_Planifier, colDateJP) < Cells(plan_Planifier, colDateJR)) And Cells(plan_Planifier, colDateJR) <> "(vide)") Then
                                                                                          retardJ = DateDiff("d", Cells(plan_Planifier, colDateJR), Cells(plan_Planifier, colDateJP))
     
                                                                                              Else
                                                                                                  If (Cells(plan_Planifier, colDateJP).Value < Date) Then
                                                                                                  retardJ = DateDiff("d", Date, Cells(plan_Planifier, colDateJP))
                                                                                                  End If
                                                                                          End If
                                                                                      End If
                                                                                      Cells(plan_Planifier, colRetard) = retardJ
                                                                                  End If
     
                                                                                 Jal = 0
                                                                                SemaineJal = 0
                                                                        End If
                                                                   End If
                                                                   z = z + 52
                                                                Loop
                                                                 z = nomColAnnee
                                                                 colonne = 0
                                                        End If
                                                    End If
                                                End If
                                        Next j
                                Next i
                                With Range(Cells(plan_Planifier + 1, 1), Cells(plan_Planifier + 1, 800)).Borders(xlEdgeBottom)
                                    .LineStyle = xlContinuous
                                    .ColorIndex = xlAutomatic
                                    .TintAndShade = 0
                                    .Weight = xlThick
                                End With
                                       plan_Planifier = plan_Planifier + 2
                                        plan_Reel = plan_Reel + 2
     
                                         Else
                                           If (IsEmpty(Cells(plan_Planifier, colTitre).Value)) Then
                                            titre = False
                                            End If
                                    End If
                        Jal = 0
                        SemaineJal = 0
                        Set numAnnee = Nothing
     
                 Loop
    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic
     MsgBox "Durée d'exécution: " & Format(Now - MacroDebut, "hh:mm:ss")
    End Sub
    J'essaye toujours de l'améliorer, mais dans tout les cas mon problème est toujours le même , le temps d'execution augmente à chaque fois que je rééxecute ma macro
    Merci encore

  8. #8
    Responsable
    Office & Excel


    Homme Profil pro
    Formateur et développeur chez EXCELLEZ.net
    Inscrit en
    Novembre 2003
    Messages
    19 122
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 57
    Localisation : Belgique

    Informations professionnelles :
    Activité : Formateur et développeur chez EXCELLEZ.net
    Secteur : Enseignement

    Informations forums :
    Inscription : Novembre 2003
    Messages : 19 122
    Points : 55 921
    Points
    55 921
    Billets dans le blog
    131
    Par défaut
    Salut.

    Je plussoie Patrice lorsqu'il dit qu'une procédure ne devrait pas dépasser une cinquantaine de lignes. L'idée serait de découper ton travail en morceaux:
    Une procédure pour transférer les données;
    Une procédure pour mettre en forme;
    ...


    De plus, je pense qu'il y a au départ un travail de conception à mettre en place, et plutôt que de tenter d'améliorer ce code, il serait à mon sens opportun de revoir la conception et la stratégie. Ici, nous ne savons pas tester ton code car il est extrêmement lié à tes feuilles, à leur conception. Les variables publiques n'arrangent rien à la chose. En découpant ton process en procédures qui n'ont qu'un seul rôle, tu pourras beaucoup mieux tester ton code étape par étape, ton code sera moins gourmand en ressources et ce sera donc tout bénéfice.

    Si tu nous mettait des copies d'écran et que tu nous expliquait ce que tu souhaites réaliser, un peu comme si tu rédigeais un cahier des charges, nous pourrions probablement mieux t'aider.
    "Plus les hommes seront éclairés, plus ils seront libres" (Voltaire)
    ---------------
    Mes billets de blog sur DVP
    Mes remarques et critiques sont purement techniques. Ne les prenez jamais pour des attaques personnelles...
    Pensez à utiliser les tableaux structurés. Ils vous simplifieront la vie, tant en Excel qu'en VBA ==> mon tuto
    Le VBA ne palliera jamais une mauvaise conception de classeur ou un manque de connaissances des outils natifs d'Excel...
    Ce ne sont pas des bonnes pratiques parce que ce sont les miennes, ce sont les miennes parce que ce sont des bonnes pratiques
    VBA pour Excel? Pensez D'ABORD en EXCEL avant de penser en VBA...
    ---------------

  9. #9
    Membre chevronné Avatar de Thumb down
    Homme Profil pro
    Retraité
    Inscrit en
    Juin 2019
    Messages
    1 420
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Juin 2019
    Messages : 1 420
    Points : 2 179
    Points
    2 179
    Par défaut
    Bonjour,
    Pour ma part, quand il s'agit d'utiliser la barre de défilement pour lire une méthode, le code est retoqué !
    Du moins jusqu'à il 3 moi ou j'étais encore en activité.

    Tu devrais pouvoir visualiser tes méthode d'un seul regard.

    Notes également que les saut de ligne n'aair pas le code mais sa lisibilité.

    Note également qu'un set variable doit toujours ce terminé par un set variable=Nothing ce qui expliquerait ta consommation mémoire.

    Tu utilises des variables public dont pour ma part je ne vois pas l'intérêt. Notes qu'une variable n'a de vie que le temps de sa portée. Une variable public temps que le fichier est ouvert, dans un procédure le temps d'exécution de la procédure

    Il faut que tu analyse ton code pour voir s'il n'y a pas de traitement redondant qui mériterait d'être factorisé dans un sub ou une function !

  10. #10
    Candidat au Club
    Femme Profil pro
    Etudiante
    Inscrit en
    Mars 2021
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 25
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Etudiante

    Informations forums :
    Inscription : Mars 2021
    Messages : 5
    Points : 3
    Points
    3
    Par défaut
    Je vous remercie infiniment pour vos conseils, ils m'ont été très utile, effectivement c’était a cause des " set variable " que j'ai pas fermé
    J'ai fait en sorte de les vides pour libérer de la place
    et j'ai remarqué qu'il y avait un boucle qui se répétait plusieurs fois avant d'afficher le resultat final, et j'ai réussi a réglé le problème,

    Mille merci et bonne journée

  11. #11
    Membre chevronné Avatar de Thumb down
    Homme Profil pro
    Retraité
    Inscrit en
    Juin 2019
    Messages
    1 420
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Juin 2019
    Messages : 1 420
    Points : 2 179
    Points
    2 179
    Par défaut
    Bonjour,
    effectivement c’était a cause des " set variable " que j'ai pas fermé
    Personnellement je préfère dire couper la liaison et pas fermer !

    Set établi une liaison entre le logiciel et un zone mémoire !

    Je pourrais faire un set fichier=Open ("c:\fichier") dans cet exemple on imagine for bien que de mettre la variable fichier à Nothing ne referme pas le dit fichier !

    En revanche assimiler Nothing à fermer pourrait faire croire le contraire !

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 0
    Dernier message: 25/06/2010, 10h38
  2. temps d'execution sui augmente.
    Par weill nathanal dans le forum Langage
    Réponses: 15
    Dernier message: 03/11/2006, 15h44
  3. limit et temps d'execution avec oracle et PHP
    Par dor_boucle dans le forum Oracle
    Réponses: 20
    Dernier message: 10/12/2005, 14h31
  4. [VB.NET] Temps d'éxécution d'une page...
    Par Webman dans le forum ASP.NET
    Réponses: 3
    Dernier message: 04/06/2004, 12h20
  5. Connaitre le temps d'execution d'un pgm ?
    Par yacinechaouche dans le forum C
    Réponses: 7
    Dernier message: 27/01/2003, 20h57

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