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 :

Procédure trop longue, pouvez vous m'aider à raccourcir?


Sujet :

Macros et VBA Excel

  1. #1
    Membre à l'essai
    Homme Profil pro
    Conducteur de chantier
    Inscrit en
    Octobre 2017
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Belgique

    Informations professionnelles :
    Activité : Conducteur de chantier
    Secteur : Bâtiment

    Informations forums :
    Inscription : Octobre 2017
    Messages : 9
    Points : 10
    Points
    10
    Par défaut Procédure trop longue, pouvez vous m'aider à raccourcir?
    Bonjour à vous,

    Voici mon problème .
    Ca ne fait qu'une quinzaine de jours ( à mes heures perdues) que j'ai découvert et commencer à faire des macro suite à une demande bien précise de madame, et oui madame veut donc ...

    J'ai une macro qui copie un tableau de 25 colonnes sur 32 lignes et qui le copie les uns en dessous des autres à chaque click
    A10:Y42
    A50:Y82
    A90:Y122
    Etc
    Pour ces tableaux, j'ai fait une macro sur un bouton à clicker après l'encodage du tableau pour une MFC et avant de clicker pour faire apparaître le tableau suivant .

    Je défini i ( numéro de lignes) par rapport à mon point de repère est a chaque fois la 1ere ligne de la colonne A du tableau . Donc dans le petit exemple ci dessus A10 puis A50 puis A90, etc
    y = i +1
    Pour ma MFC (3 couleurs), je sélectionne
    Range("B" & y).Resize(Row + 25).Select
    La MFC a pour 1er critère nombre =0, pour 2eme critère nombre = Cells (y, "C") /2 et pour 3eme critère nombre = Cells (y, "C")
    Puis je recommence avec ("D" & y) pour Cells(y, "E") puis avec ("F" & y) pour Cells(y, "G") et ainsi de suite jusque ("V" & y) pour Cells(y, "W")

    Puis je peux encore le faire avec ("B" & a) pour Cells(a, "C"), ...... , ("V" & a) pour Cells(a, "W") ou a = y +26

    Et la j' arrive au bout de la macro, mais je devrais encore pouvoir le faire pour 4 lignes .

    Voila en gros.

    j'ai essayer de trouver une solution . Mais mes petites nouvelles connaissances ne me permettent pas d'aller plus loin

    Merci d'avance
    Spid

  2. #2
    Membre extrêmement actif
    Homme Profil pro
    aucune
    Inscrit en
    Avril 2016
    Messages
    7 563
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 82
    Localisation : France, Pyrénées Atlantiques (Aquitaine)

    Informations professionnelles :
    Activité : aucune

    Informations forums :
    Inscription : Avril 2016
    Messages : 7 563
    Points : 12 422
    Points
    12 422
    Par défaut
    Bonjour
    J'ai des difficultés à comprendre où se situe ton problème.
    Est-ce pour faire tes mises en forme conditionnelles ?
    ou
    Est-ce pour copier les unes sous les autres des plages de cellules que tu spécifies (qu'elles soient ou non mises en forme) ?

    PS : la règle est ici de montrer (entre balises code) le code tenté ... (pas le classeur, hein ... juste le code)
    Comment imaginer que l'on puisse raccourcir un code non montré ?
    Je n'accepte pas de demande d' "amitié" individuelle. Tout développeur est pour moi un ami.
    Je n'ouvre AUCUN classeur tiers (avec ou sans macro ******). Ne m'en proposez donc pas .

    ****** : Non, non ... un classeur .xlsx ne "peut" par exemple et entre autres pas contenir un activex (de surcroît invisible) , "bien sûr" ...

    Il est illusoire de penser que l'on saurait exprimer valablement et précisément en un langage (rigide) de développement ce que l'on peine à exprimer dans le langage naturel, bien plus souple.

  3. #3
    Membre à l'essai
    Homme Profil pro
    Conducteur de chantier
    Inscrit en
    Octobre 2017
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Belgique

    Informations professionnelles :
    Activité : Conducteur de chantier
    Secteur : Bâtiment

    Informations forums :
    Inscription : Octobre 2017
    Messages : 9
    Points : 10
    Points
    10
    Par défaut
    Oui je me doutais que ça ne serait pas facile sans le voir mais j'avais lu qu'on ne pouvait pas le mettre directement dans le premier post .

    Donc le voici

    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
     
    Sub MFC()
     
        Dim derlg As Long, i As Long
    derlg = Range("A" & Rows.Count).End(xlUp).Row
    For i = derlg To 1 Step -1
        If Range("A" & i) = "Nom de l'élève" Then Exit For
     
        For y = i + 1 To 1 Step 1
    Next y
     
    Next i
     
     
        Range("B" & y).Resize(Row + 30).Select
        Selection.FormatConditions.Delete
        Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
            Formula1:="=""R"""
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        With Selection.FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = 15773696
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).StopIfTrue = False
        Application.CutCopyMode = False
        Selection.FormatConditions.AddColorScale ColorScaleType:=3
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(1).Value = 0
        With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor
            .Color = 255
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(2).Value = Cells(y, "C") / 2
        With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor
            .Color = 65535
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(3).Value = Cells(y, "C")
        With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor
            .Color = 5287936
            .TintAndShade = 0
        End With
     
        Range("D" & y).Resize(Row + 30).Select
        Selection.FormatConditions.Delete
        Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
            Formula1:="=""R"""
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        With Selection.FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = 15773696
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).StopIfTrue = False
        Application.CutCopyMode = False
        Selection.FormatConditions.AddColorScale ColorScaleType:=3
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(1).Value = 0
        With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor
            .Color = 255
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(2).Value = Cells(y, 5) / 2
        With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor
            .Color = 65535
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(3).Value = Cells(y, "E")
        With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor
            .Color = 5287936
            .TintAndShade = 0
        End With
     
        Range("F" & y).Resize(Row + 30).Select
        Selection.FormatConditions.Delete
        Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
            Formula1:="=""R"""
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        With Selection.FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = 15773696
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).StopIfTrue = False
        Application.CutCopyMode = False
        Selection.FormatConditions.AddColorScale ColorScaleType:=3
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(1).Value = 0
        With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor
            .Color = 255
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(2).Value = Cells(y, "G") / 2
        With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor
            .Color = 65535
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(3).Value = Cells(y, "G")
        With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor
            .Color = 5287936
            .TintAndShade = 0
        End With
     
        Range("H" & y).Resize(Row + 30).Select
        Selection.FormatConditions.Delete
        Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
            Formula1:="=""R"""
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        With Selection.FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = 15773696
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).StopIfTrue = False
        Application.CutCopyMode = False
        Selection.FormatConditions.AddColorScale ColorScaleType:=3
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(1).Value = 0
        With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor
            .Color = 255
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(2).Value = Cells(y, "I") / 2
        With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor
            .Color = 65535
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(3).Value = Cells(y, "I")
        With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor
            .Color = 5287936
            .TintAndShade = 0
        End With
     
        Range("J" & y).Resize(Row + 30).Select
        Selection.FormatConditions.Delete
        Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
            Formula1:="=""R"""
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        With Selection.FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = 15773696
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).StopIfTrue = False
        Application.CutCopyMode = False
        Selection.FormatConditions.AddColorScale ColorScaleType:=3
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(1).Value = 0
        With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor
            .Color = 255
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(2).Value = Cells(y, "K") / 2
        With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor
            .Color = 65535
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(3).Value = Cells(y, "K")
        With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor
            .Color = 5287936
            .TintAndShade = 0
        End With
        Range("L" & y).Resize(Row + 30).Select
        Selection.FormatConditions.Delete
        Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
            Formula1:="=""R"""
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        With Selection.FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = 15773696
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).StopIfTrue = False
        Application.CutCopyMode = False
        Selection.FormatConditions.AddColorScale ColorScaleType:=3
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(1).Value = 0
        With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor
            .Color = 255
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(2).Value = Cells(y, "M") / 2
        With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor
            .Color = 65535
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(3).Value = Cells(y, "M")
        With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor
            .Color = 5287936
            .TintAndShade = 0
        End With
     
        Range("N" & y).Resize(Row + 30).Select
        Selection.FormatConditions.Delete
        Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
            Formula1:="=""R"""
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        With Selection.FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = 15773696
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).StopIfTrue = False
        Application.CutCopyMode = False
        Selection.FormatConditions.AddColorScale ColorScaleType:=3
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(1).Value = 0
        With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor
            .Color = 255
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(2).Value = Cells(y, "O") / 2
        With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor
            .Color = 65535
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(3).Value = Cells(y, "O")
        With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor
            .Color = 5287936
            .TintAndShade = 0
        End With
     
        Range("P" & y).Resize(Row + 30).Select
        Selection.FormatConditions.Delete
        Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
            Formula1:="=""R"""
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        With Selection.FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = 15773696
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).StopIfTrue = False
        Application.CutCopyMode = False
        Selection.FormatConditions.AddColorScale ColorScaleType:=3
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(1).Value = 0
        With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor
            .Color = 255
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(2).Value = Cells(y, "Q") / 2
        With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor
            .Color = 65535
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(3).Value = Cells(y, "Q")
        With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor
            .Color = 5287936
            .TintAndShade = 0
        End With
     
        Range("R" & y).Resize(Row + 30).Select
        Selection.FormatConditions.Delete
        Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
            Formula1:="=""R"""
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        With Selection.FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = 15773696
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).StopIfTrue = False
        Application.CutCopyMode = False
        Selection.FormatConditions.AddColorScale ColorScaleType:=3
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(1).Value = 0
        With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor
            .Color = 255
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(2).Value = Cells(y, "S") / 2
        With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor
            .Color = 65535
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(3).Value = Cells(y, "S")
        With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor
            .Color = 5287936
            .TintAndShade = 0
        End With
     
        Range("T" & y).Resize(Row + 30).Select
        Selection.FormatConditions.Delete
        Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
            Formula1:="=""R"""
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        With Selection.FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = 15773696
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).StopIfTrue = False
        Application.CutCopyMode = False
        Selection.FormatConditions.AddColorScale ColorScaleType:=3
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(1).Value = 0
        With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor
            .Color = 255
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(2).Value = Cells(y, "U") / 2
        With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor
            .Color = 65535
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(3).Value = Cells(y, "U")
        With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor
            .Color = 5287936
            .TintAndShade = 0
        End With
     
        Range("V" & y).Resize(Row + 30).Select
        Selection.FormatConditions.Delete
        Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
            Formula1:="=""R"""
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        With Selection.FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = 15773696
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).StopIfTrue = False
        Application.CutCopyMode = False
        Selection.FormatConditions.AddColorScale ColorScaleType:=3
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(1).Value = 0
        With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor
            .Color = 255
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(2).Value = Cells(y, "W") / 2
        With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor
            .Color = 65535
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _
            xlConditionValueNumber
        Selection.FormatConditions(1).ColorScaleCriteria(3).Value = Cells(y, "W")
        With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor
            .Color = 5287936
            .TintAndShade = 0
        End With
     
     
    End Sub
    Ce n'est que du copier/coller avec peux de valeur qui changent .
    Et j'ai encore 5 lignes où la cellule Bx va avec Cx, Dx va avec Ex, Fx va avec Gx , ... Vx va avec Wx
    By va avec Cy, Dy va avec Ey
    etc

  4. #4
    Membre extrêmement actif
    Homme Profil pro
    aucune
    Inscrit en
    Avril 2016
    Messages
    7 563
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 82
    Localisation : France, Pyrénées Atlantiques (Aquitaine)

    Informations professionnelles :
    Activité : aucune

    Informations forums :
    Inscription : Avril 2016
    Messages : 7 563
    Points : 12 422
    Points
    12 422
    Par défaut
    mais j'avais lu qu'on ne pouvait pas le mettre directement dans le premier poste
    où diable as-tu lu une telle chose.
    Ce que tu as lu ne concerne pas le code, mais le dépôt de classeurs (que je n'ouvre d'ailleurs personnellement jamais - question de sécurité - , que ce soit lors du 1er message ou des messages suivants !)

    Avant d'aller plus loin : ton code appelle de ma part un certain "étonnement" :
    Explique, juste pour voir, la finalité de ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    Dim y As Long
        For y = i + 1 To 1 Step 1
    Next y

    J'attends par ailleurs que tu veuilles bien répondre à la question que je t'ai posée :
    Est-ce pour faire tes mises en forme conditionnelles ?
    ou
    Est-ce pour copier les unes sous les autres des plages de cellules que tu spécifies (qu'elles soient ou non mises en forme) ?
    Je n'accepte pas de demande d' "amitié" individuelle. Tout développeur est pour moi un ami.
    Je n'ouvre AUCUN classeur tiers (avec ou sans macro ******). Ne m'en proposez donc pas .

    ****** : Non, non ... un classeur .xlsx ne "peut" par exemple et entre autres pas contenir un activex (de surcroît invisible) , "bien sûr" ...

    Il est illusoire de penser que l'on saurait exprimer valablement et précisément en un langage (rigide) de développement ce que l'on peine à exprimer dans le langage naturel, bien plus souple.

  5. #5
    Membre extrêmement actif
    Homme Profil pro
    aucune
    Inscrit en
    Avril 2016
    Messages
    7 563
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 82
    Localisation : France, Pyrénées Atlantiques (Aquitaine)

    Informations professionnelles :
    Activité : aucune

    Informations forums :
    Inscription : Avril 2016
    Messages : 7 563
    Points : 12 422
    Points
    12 422
    Par défaut
    Je viens de parcourir ton code.
    Je n'y vois aucune "copie" qui correspondrait à :
    J'ai une macro qui copie un tableau de 25 colonnes sur 32 lignes et qui le copie les uns en dessous des autres
    J'y vois par contre des séries d'instructions de mise en forme.
    Elles devraient être mises dans une seule procédure paramétrée, appelée chaque fois en lui passant les paramètres nécessaires.

    Voici un exemple du mécanisme dont je parle --->>

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    Private Sub CommandButton1_Click()
      toto "blabla", 3, CDate("01/01/2017"), Range("H1")
      toto "blibli", 5, CDate("015/11/2018"), Range("H2")
    End Sub
     
    Private Sub toto(t As String, n1 As Integer, d1 As Date, cellule As Range)
      With cellule
         .Value = t
         .Offset(0, 1) = n1
         .Offset(0, 2) = d1
      End With
    End Sub
    Je n'accepte pas de demande d' "amitié" individuelle. Tout développeur est pour moi un ami.
    Je n'ouvre AUCUN classeur tiers (avec ou sans macro ******). Ne m'en proposez donc pas .

    ****** : Non, non ... un classeur .xlsx ne "peut" par exemple et entre autres pas contenir un activex (de surcroît invisible) , "bien sûr" ...

    Il est illusoire de penser que l'on saurait exprimer valablement et précisément en un langage (rigide) de développement ce que l'on peine à exprimer dans le langage naturel, bien plus souple.

  6. #6
    Membre à l'essai
    Homme Profil pro
    Conducteur de chantier
    Inscrit en
    Octobre 2017
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Belgique

    Informations professionnelles :
    Activité : Conducteur de chantier
    Secteur : Bâtiment

    Informations forums :
    Inscription : Octobre 2017
    Messages : 9
    Points : 10
    Points
    10
    Par défaut
    Comme je l'ai dit, je suis tout nouveau dans le vba, et n'y connaissait rien du tout il y a 15 jours. Donc je fais avec les moyens du bord avec les informations que j'arrive a trouver sur les forums.
    il est donc fort possible que je me complique la vie pour pas grand chose .

    J'ai défini For y = i +1 to 1 . Et maintenant je pense que j'aurais juste pu mettre ça
    Parce que je ne savais pas si je pouvais faire Range("B" & i + 1).Resize (Row + 25).Select

    En fait mon code marche bien, mais je n'ai pas assez de place dans la macro pour faire toute mes lignes

    voila la résultat que je recherche

    Nom : Vba.PNG
Affichages : 162
Taille : 75,4 Ko

    J'ai mis ce code en place, parce que je copie un tableau sans MFC .
    Si je le copie avec la MFC, la cellule cible du type $C$12 reste toujours la même vu que c'est une cellule figée.
    mais a chaque copie de tableau j'ai besoin que la cellule cible changent et à la différence de l'image ou j'ai fait un test couleur C12<>E12<>G12<> etc
    De C12 à C36 la valeur reste la même mais peut être modifiée de C37 à C42
    de E12 à E36 la valeur reste la même mais peut être modifiée de E12 à E42
    Etc

  7. #7
    Membre extrêmement actif
    Homme Profil pro
    aucune
    Inscrit en
    Avril 2016
    Messages
    7 563
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 82
    Localisation : France, Pyrénées Atlantiques (Aquitaine)

    Informations professionnelles :
    Activité : aucune

    Informations forums :
    Inscription : Avril 2016
    Messages : 7 563
    Points : 12 422
    Points
    12 422
    Par défaut
    Je ne sais pas ce que tu "fabriques".
    Je vais donc m'en tenir à la réponse à :
    En fait mon code marche bien, mais je n'ai pas assez de place dans la macro pour faire toute mes lignes
    Je te l'ai donnée plus haut : procédure paramétrée (je t'ai montré un exemple de ce que c'est).

    Ps : dans la foulée : ouvre donc ton aide interne VBA à la rubrique Range.Find, méthode et utilise-la donc en lieu et place d'une boucle pour chercher "nom de l'élève"
    Consulte également la rubrique Range.Offset, propriété. Elle te permettra d'éviter de passer par addition d'une ligne à l'autre.
    Je n'accepte pas de demande d' "amitié" individuelle. Tout développeur est pour moi un ami.
    Je n'ouvre AUCUN classeur tiers (avec ou sans macro ******). Ne m'en proposez donc pas .

    ****** : Non, non ... un classeur .xlsx ne "peut" par exemple et entre autres pas contenir un activex (de surcroît invisible) , "bien sûr" ...

    Il est illusoire de penser que l'on saurait exprimer valablement et précisément en un langage (rigide) de développement ce que l'on peine à exprimer dans le langage naturel, bien plus souple.

  8. #8
    Membre à l'essai
    Homme Profil pro
    Conducteur de chantier
    Inscrit en
    Octobre 2017
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Belgique

    Informations professionnelles :
    Activité : Conducteur de chantier
    Secteur : Bâtiment

    Informations forums :
    Inscription : Octobre 2017
    Messages : 9
    Points : 10
    Points
    10
    Par défaut
    Citation Envoyé par unparia Voir le message
    Je viens de parcourir ton code.
    Je n'y vois aucune "copie" qui correspondrait à :

    J'y vois par contre des séries d'instructions de mise en forme.
    Elles devraient être mises dans une seule procédure paramétrée, appelée chaque fois en lui passant les paramètres nécessaires.

    Voici un exemple du mécanisme dont je parle --->>

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    Private Sub CommandButton1_Click()
      toto "blabla", 3, CDate("01/01/2017"), Range("H1")
      toto "blibli", 5, CDate("015/11/2018"), Range("H2")
    End Sub
     
    Private Sub toto(t As String, n1 As Integer, d1 As Date, cellule As Range)
      With cellule
         .Value = t
         .Offset(0, 1) = n1
         .Offset(0, 2) = d1
      End With
    End Sub
    J'ai 2 macros un bouton qui copie un tableau vierge ( nouvelle évaluation) et un bouton pour la MFC ( mise en couleur) qui doit être activé après l'encodage des données dans le tableau
    j'avais essayer en un seul mais je n'y arrivais pas

  9. #9
    Membre à l'essai
    Homme Profil pro
    Conducteur de chantier
    Inscrit en
    Octobre 2017
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Belgique

    Informations professionnelles :
    Activité : Conducteur de chantier
    Secteur : Bâtiment

    Informations forums :
    Inscription : Octobre 2017
    Messages : 9
    Points : 10
    Points
    10
    Par défaut
    Citation Envoyé par unparia Voir le message
    Je ne sais pas ce que tu "fabriques".
    Je vais donc m'en tenir à la réponse à :

    Je te l'ai donnée plus haut : procédure paramétrée (je t'ai montré un exemple de ce que c'est).

    Ps : dans la foulée : ouvre donc ton aide interne VBA à la rubrique Range.Find, méthode et utilise-la donc en lieu et place d'une boucle pour chercher "nom de l'élève"
    Ok merçi, je vais regarder a ça.
    Pas facile de débuter
    Bonne fin de soirée

  10. #10
    Membre extrêmement actif
    Homme Profil pro
    aucune
    Inscrit en
    Avril 2016
    Messages
    7 563
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 82
    Localisation : France, Pyrénées Atlantiques (Aquitaine)

    Informations professionnelles :
    Activité : aucune

    Informations forums :
    Inscription : Avril 2016
    Messages : 7 563
    Points : 12 422
    Points
    12 422
    Par défaut
    Là s'arrête mon intervention. Elle est là pour définir un rail à suivre. Et il est facile à suivre.

    Pas facile de débuter
    Je ne me rappelle pas avoir trouvé cela difficile ... Au contraire : moins monotone qu'aujourd'hui... (beaucoup moins...)
    Je n'accepte pas de demande d' "amitié" individuelle. Tout développeur est pour moi un ami.
    Je n'ouvre AUCUN classeur tiers (avec ou sans macro ******). Ne m'en proposez donc pas .

    ****** : Non, non ... un classeur .xlsx ne "peut" par exemple et entre autres pas contenir un activex (de surcroît invisible) , "bien sûr" ...

    Il est illusoire de penser que l'on saurait exprimer valablement et précisément en un langage (rigide) de développement ce que l'on peine à exprimer dans le langage naturel, bien plus souple.

Discussions similaires

  1. [Vba access 97] Procédure trop longue
    Par saufffy dans le forum Access
    Réponses: 6
    Dernier message: 26/02/2007, 10h40
  2. Je n'arrive pas à faire une pop-up. Pouvez-vous m'aider?
    Par Davidoux94 dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 01/12/2006, 12h24
  3. [ASE] Procèdure trop longue
    Par Benjamin78 dans le forum Sybase
    Réponses: 2
    Dernier message: 11/04/2006, 10h01
  4. [ASE][T-SQL]Procédure trop longue
    Par Benjamin78 dans le forum Sybase
    Réponses: 5
    Dernier message: 21/03/2006, 12h25
  5. Pouvez vous m'aider a resoudres ces 3 exercices
    Par algorithmique dans le forum Algorithmes et structures de données
    Réponses: 11
    Dernier message: 09/08/2002, 17h26

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