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 :

Creer une variable tableau avec une partie fixe de son nom et une partie variable?


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Homme Profil pro
    technicien
    Inscrit en
    Février 2017
    Messages
    82
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : technicien

    Informations forums :
    Inscription : Février 2017
    Messages : 82
    Par défaut Creer une variable tableau avec une partie fixe de son nom et une partie variable?
    Bonjour à tous.
    Est il possible de créer une variable tableau avec une partie fixe de son nom et une partie variable?

    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
    Sub variable()
    Dim malist()
    Dim tablo & element()' comment on déclare cela?
    
    Const fixe As String = "tablo"
    maliste = Array("tutu", "tata")
    For Each element In maliste
    
    If element = "tutu" Then
     ' la variable tableau s'appelle dans ce cas tablotutu()
    
    tablotutu = ActiveWorkbook.Sheets("Feuil2").Range("A4:A20")
    End If
    
    If element = "tata" Then
    ' la variable tableau s'appelle dans ce cas tablotata()
    
    tablotata = ActiveWorkbook.Sheets("Feuil2").Range("C4:C20")
    End If
    
    Next element
    
    End Sub
    Merci par avance.

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

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

    Informations forums :
    Inscription : Octobre 2016
    Messages : 1 703
    Par défaut
    Bonjour,
    Non, ce n'est pas possible.
    Quel est le but de cet manipulation? Est-ce que tu veux créer plusieurs tableaux? Tu peux faire un tableau de tableau.
    Est-ce que tu as besoin de savoir quel tableau est lié à quelle variable titi, tutu, toto ....? Je pense que tu peux utiliser un dictionnaire de tableau à ce moment-là. La clefs étant le tutu, titi, toto ... et la valeur le tableau. Ainsi, si tu veux récupérer le tableau tutu :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    dictionnaire.Item("tutu")
    Ici le tuto du site de Boisgontier sur les dictionnaires.

  3. #3
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 374
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 374
    Billets dans le blog
    8
    Par défaut re
    're
    bonjour pluto que d'engager un dictionnaire et toute la scrun.dll qui va avec intéresse toi au variable typées
    ca pourrait intéresser raiolle aussi
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    Private Type nom
        toto As Variant
        titi As Variant
        End Type
    Dim mestableaux As nom
    Sub test()
        mestableaux.toto = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)
        mestableaux.titi = Array("a", "b", "c", "d", "e")
        MsgBox UBound(mestableaux.toto)
        MsgBox UBound(mestableaux.titi)
     End Sub
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  4. #4
    Membre confirmé
    Homme Profil pro
    technicien
    Inscrit en
    Février 2017
    Messages
    82
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : technicien

    Informations forums :
    Inscription : Février 2017
    Messages : 82
    Par défaut
    Merci pour le retour.
    Patricktoulon je n'arrive pas à conceptualiser cette variable typée et la gestion de celle-ci (je regarde l'aide sur array). De ce que j'ai compris dans l'exemple, unbound toto renvoie 8 (0 à 8) et titi renvoie 4 (0 à 4). Mais après je passe comment de l'un à l'autre?

    Riaolle j'ai déjà pas mal consulté les tutos de Jacques Boisgontier ( c'est extra mais et ) et c'est en tombant dessus que j'ai décidé de regarder les dictionnaires et les variables tableau de plus près. En fait j'ai 12 fois le même code (composé d'une 20 aine de lignes) la seule chose qui diffère c'est le critère de recherche. Si j'ai "tutu" j'écris dans la variable tablotutu, si j'ai "tata" j'écris dans la variable tablotata , si j'ai "titi" je le donne en 1000 tablotiti ect ect. J'aimerais condenser ces 12 pavés en un seul.

    Pour ne pas froisser joelevrai, la première méthode utilisant 12 variables tableau est un poil plus rapide que les filtres avancés. J'aboutis bien au même résultats et c'est extra de voir toutes les façon d'y arriver...
    Dans les deux cas c'est vraiment génial j'ai pas mal appris (mais pas encore assez).

    pour toutes les aides elles me sont très très précieuses.

  5. #5
    Membre confirmé
    Homme Profil pro
    technicien
    Inscrit en
    Février 2017
    Messages
    82
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : technicien

    Informations forums :
    Inscription : Février 2017
    Messages : 82
    Par défaut
    Pour Marc L et les autres désolé si je ne suis pas clair mais j’essaie par des exemples simples de trouver ce qui peut correspondre.
    J'ai ce type de listing (d un nombre inconnu de lignes)
    Nom : marcl.jpg
Affichages : 1578
Taille : 251,6 Ko

    J'analyse ce listing pour:
    - 1) faire un tableau de synthèse (c'est ma variable tablo),
    - 2) faire un graphique en nuage de points extraits de mes fameuses variables qui ont le même début de nom.
    - 3) utiliser ces variables pour faire dans un autre fichier Excel la compilation de plusieurs journées d'exploitations.

    Voici le code très long reproduit quasiment à l'identique 12 fois seul le critère de recherche (titi, tata, tutu..) et l'incrémentation dans ces variables.
    Je souhaite condenser ces paquets de 12 en 1...
    Désolé pour la longueur do code mais c'est bien pour le réduire (tout en gardant cette approche car super rapide) que je poste....

    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
     
    Sub test()
    Dim zone As Variant
    Dim tablodtiti() As Variant
    Dim tablodtata() As Variant
    Dim tablodtutu() As Variant
    Dim tablodtyty() As Variant
    Dim tablodtoto() As Variant
    Dim tablodtgtg() As Variant
    Dim tabloatiti() As Variant
    Dim tabloatata() As Variant
    Dim tabloatutu() As Variant
    Dim tabloatyty() As Variant
    Dim tabloatoto() As Variant
    Dim tabloatgtg() As Variant
    Dim tablo(12, 8) As Variant
    Dim i As Integer, c As Integer, d As Integer, e As Integer, f As Integer, g As Integer, h As Integer
    Dim c2 As Integer, d2 As Integer, e2 As Integer, f2 As Integer, g2 As Integer, h2 As Integer
     
     
     
    Application.ScreenUpdating = False
     
    'enregistre la plage d'analyse dans la variable zone
    zone = Workbooks("Copie").Sheets("Feuil1").Range("A1").CurrentRegion
     
    For i = LBound(zone, 1) To UBound(zone, 1)
     
            If zone(i, 4) = "titi" Then
            c = c + 1
            ReDim Preserve tablodtiti(c)
     
            tablodtiti(c) = Application.Index(zone, i)
            tablo(1, 1) = c
            'trouve la valeur min et l'écrit dans le tableau de synthese
            tablo(1, 2) = Application.Min(Application.Index(tablodtiti, , 3))
            'trouve la valeur max et l'écrit dans le tableau de synthese
            tablo(1, 3) = Application.Max(Application.Index(tablodtiti, , 3))
            'quantité inf 1000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtiti(c), , 3)) < 1000 Then
                tablo(1, 4) = tablo(1, 4) + 1
                End If
            'quantité 1000/2000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtiti(c), , 3)) >= 1000 And Application.Min(Application.Index(tablodtiti(c), , 3)) < 2000 Then
                tablo(1, 5) = tablo(1, 5) + 1
                End If
            'quantité 2000/3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtiti(c), , 3)) >= 2000 And Application.Min(Application.Index(tablodtiti(c), , 3)) < 3000 Then
                tablo(1, 6) = tablo(1, 6) + 1
                End If
            'quantité sup 3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtiti(c), , 3)) >= 3000 Then
                tablo(1, 7) = tablo(1, 7) + 1
                End If
            'calculs la moyenne
            tablo(1, 8) = Application.Average(Application.Index(tablodtiti, , 3))
            End If
     
     
        If zone(i, 4) = "tata" Then
            d = d + 1
            ReDim Preserve tablodtata(d)
     
            tablodtata(d) = Application.Index(zone, i)
            tablo(3, 1) = d
            'trouve la valeur min et l'écrit dans le tableau de synthese
            tablo(3, 2) = Application.Min(Application.Index(tablodtata, , 3))
            'trouve la valeur max et l'écrit dans le tableau de synthese
            tablo(3, 3) = Application.Max(Application.Index(tablodtata, , 3))
            'quantité inf 1000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtata(d), , 3)) < 1000 Then
                tablo(3, 4) = tablo(3, 4) + 1
                End If
            'quantité 1000/2000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtata(d), , 3)) >= 1000 And Application.Min(Application.Index(tablodtata(d), , 3)) < 2000 Then
                tablo(3, 5) = tablo(3, 5) + 1
                End If
            'quantité 2000/3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtata(d), , 3)) >= 2000 And Application.Min(Application.Index(tablodtata(d), , 3)) < 3000 Then
                tablo(3, 6) = tablo(3, 6) + 1
                End If
            'quantité sup 3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtata(d), , 3)) >= 3000 Then
                tablo(3, 7) = tablo(3, 7) + 1
                End If
            'calculs la moyenne
            tablo(3, 8) = Application.Average(Application.Index(tablodtata, , 3))
            End If
     
     
            If zone(i, 4) = "tutu" Then
            e = e + 1
            ReDim Preserve tablodtutu(e)
     
            tablodtutu(e) = Application.Index(zone, i)
            tablo(5, 1) = e
            'trouve la valeur min et l'écrit dans le tableau de synthese
            tablo(5, 2) = Application.Min(Application.Index(tablodtutu, , 3))
            'trouve la valeur max et l'écrit dans le tableau de synthese
            tablo(5, 3) = Application.Max(Application.Index(tablodtutu, , 3))
            'quantité inf 1000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtutu(e), , 3)) < 1000 Then
                tablo(5, 4) = tablo(5, 4) + 1
                End If
            'quantité 1000/2000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtutu(e), , 3)) >= 1000 And Application.Min(Application.Index(tablodtutu(e), , 3)) < 2000 Then
                tablo(5, 5) = tablo(5, 5) + 1
                End If
            'quantité 2000/3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtutu(e), , 3)) >= 2000 And Application.Min(Application.Index(tablodtutu(e), , 3)) < 3000 Then
                tablo(5, 6) = tablo(5, 6) + 1
                End If
            'quantité sup 3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtutu(e), , 3)) >= 3000 Then
                tablo(5, 7) = tablo(5, 7) + 1
                End If
            'calculs la moyenne
            tablo(5, 8) = Application.Average(Application.Index(tablodtutu, , 3))
            End If
     
     
            If zone(i, 4) = "toto" Then
            f = f + 1
            ReDim Preserve tablodtoto(f)
     
            tablodtoto(f) = Application.Index(zone, i)
            tablo(7, 1) = f
            'trouve la valeur min et l'écrit dans le tableau de synthese
            tablo(7, 2) = Application.Min(Application.Index(tablodtoto, , 3))
            'trouve la valeur max et l'écrit dans le tableau de synthese
            tablo(7, 3) = Application.Max(Application.Index(tablodtoto, , 3))
            'quantité inf 1000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtoto(f), , 3)) < 1000 Then
                tablo(7, 4) = tablo(7, 4) + 1
                End If
            'quantité 1000/2000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtoto(f), , 3)) >= 1000 And Application.Min(Application.Index(tablodtoto(f), , 3)) < 2000 Then
                tablo(7, 5) = tablo(7, 5) + 1
                End If
            'quantité 2000/3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtoto(f), , 3)) >= 2000 And Application.Min(Application.Index(tablodtoto(f), , 3)) < 3000 Then
                tablo(7, 6) = tablo(7, 6) + 1
                End If
            'quantité sup 3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtoto(f), , 3)) >= 3000 Then
                tablo(7, 7) = tablo(7, 7) + 1
                End If
            'calculs la moyenne
            tablo(7, 8) = Application.Average(Application.Index(tablodtoto, , 3))
            End If
     
     
            If zone(i, 4) = "LFtyty" Then
            g = g + 1
            ReDim Preserve tablodtyty(g)
     
            tablodtyty(g) = Application.Index(zone, i)
            tablo(9, 1) = g
            'trouve la valeur min et l'écrit dans le tableau de synthese
            tablo(9, 2) = Application.Min(Application.Index(tablodtyty, , 3))
            'trouve la valeur max et l'écrit dans le tableau de synthese
            tablo(9, 3) = Application.Max(Application.Index(tablodtyty, , 3))
            'quantité inf 1000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtyty(g), , 3)) < 1000 Then
                tablo(9, 4) = tablo(9, 4) + 1
                End If
            'quantité 1000/2000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtyty(g), , 3)) >= 1000 And Application.Min(Application.Index(tablodtyty(g), , 3)) < 2000 Then
                tablo(9, 5) = tablo(9, 5) + 1
                End If
            'quantité 2000/3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtyty(g), , 3)) >= 2000 And Application.Min(Application.Index(tablodtyty(g), , 3)) < 3000 Then
                tablo(9, 6) = tablo(9, 6) + 1
                End If
            'quantité sup 3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtyty(g), , 3)) >= 3000 Then
                tablo(9, 7) = tablo(9, 7) + 1
                End If
            'calculs la moyenne
            tablo(9, 8) = Application.Average(Application.Index(tablodtyty, , 3))
            End If
     
     
            If zone(i, 4) = "tgtg" Then
            h = h + 1
            ReDim Preserve tablodtgtg(h)
     
            tablodtgtg(h) = Application.Index(zone, i)
            tablo(11, 1) = h
            'trouve la valeur min et l'écrit dans le tableau de synthese
            tablo(11, 2) = Application.Min(Application.Index(tablodtgtg, , 3))
            'trouve la valeur max et l'écrit dans le tableau de synthese
            tablo(11, 3) = Application.Max(Application.Index(tablodtgtg, , 3))
            'quantité inf 1000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtgtg(h), , 3)) < 1000 Then
                tablo(11, 4) = tablo(11, 4) + 1
                End If
            'quantité 1000/2000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtgtg(h), , 3)) >= 1000 And Application.Min(Application.Index(tablodtgtg(h), , 3)) < 2000 Then
                tablo(11, 5) = tablo(11, 5) + 1
                End If
            'quantité 2000/3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtgtg(h), , 3)) >= 2000 And Application.Min(Application.Index(tablodtgtg(h), , 3)) < 3000 Then
                tablo(11, 6) = tablo(11, 6) + 1
                End If
            'quantité sup 3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tablodtgtg(h), , 3)) >= 3000 Then
                tablo(11, 7) = tablo(11, 7) + 1
                End If
            'calculs la moyenne des mvts concernées et l'écrit dans le tableau de synthese
            tablo(11, 8) = Application.Average(Application.Index(tablodtgtg, , 3))
            End If
     
            If zone(i, 5) = "titi" Then
            c2 = c2 + 1
            ReDim Preserve tabloatiti(c2)
     
            tabloatiti(c2) = Application.Index(zone, i)
            tablo(2, 1) = c2 'écrit la quantité de départs titi dans le tableau de synthese
            'trouve la valeur min et l'écrit dans le tableau de synthese
            tablo(2, 2) = Application.Min(Application.Index(tabloatiti, , 3))
            'trouve la valeur max et l'écrit dans le tableau de synthese
            tablo(2, 3) = Application.Max(Application.Index(tabloatiti, , 3))
            'quantité inf 1000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatiti(c2), , 3)) < 1000 Then
                tablo(2, 4) = tablo(2, 4) + 1
                End If
            'quantité 1000/2000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatiti(c2), , 3)) >= 1000 And Application.Min(Application.Index(tabloatiti(c2), , 3)) < 2000 Then
                tablo(2, 5) = tablo(2, 5) + 1
                End If
            'quantité 2000/3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatiti(c2), , 3)) >= 2000 And Application.Min(Application.Index(tabloatiti(c2), , 3)) < 3000 Then
                tablo(2, 6) = tablo(2, 6) + 1
                End If
            'quantité sup 3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatiti(c2), , 3)) >= 3000 Then
                tablo(2, 7) = tablo(2, 7) + 1
                End If
            'calculs la moyenne
            tablo(2, 8) = Application.Average(Application.Index(tabloatiti, , 3))
            End If
     
     
        If zone(i, 5) = "tata" Then
            d2 = d2 + 1
            ReDim Preserve tabloatata(d2)
     
            tabloatata(d2) = Application.Index(zone, i)
            tablo(4, 1) = d2 'écrit la quantité de départs titi dans le tableau de synthese
            'trouve la valeur min et l'écrit dans le tableau de synthese
            tablo(4, 2) = Application.Min(Application.Index(tabloatata, , 3))
            'trouve la valeur max et l'écrit dans le tableau de synthese
            tablo(4, 3) = Application.Max(Application.Index(tabloatata, , 3))
            'quantité inf 1000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatata(d2), , 3)) < 1000 Then
                tablo(4, 4) = tablo(4, 4) + 1
                End If
            'quantité 1000/2000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatata(d2), , 3)) >= 1000 And Application.Min(Application.Index(tabloatata(d2), , 3)) < 2000 Then
                tablo(4, 5) = tablo(4, 5) + 1
                End If
            'quantité 2000/3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatata(d2), , 3)) >= 2000 And Application.Min(Application.Index(tabloatata(d2), , 3)) < 3000 Then
                tablo(4, 6) = tablo(4, 6) + 1
                End If
            'quantité sup 3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatata(d2), , 3)) >= 3000 Then
                tablo(4, 7) = tablo(4, 7) + 1
                End If
            'calculs la moyenne
            tablo(4, 8) = Application.Average(Application.Index(tabloatata, , 3))
            End If
     
     
            If zone(i, 5) = "tutu" Then
            e2 = e2 + 1
            ReDim Preserve tabloatutu(e2)
     
            tabloatutu(e2) = Application.Index(zone, i)
            tablo(6, 1) = e2
            'trouve la valeur min et l'écrit dans le tableau de synthese
            tablo(6, 2) = Application.Min(Application.Index(tabloatutu, , 3))
            'trouve la valeur max et l'écrit dans le tableau de synthese
            tablo(6, 3) = Application.Max(Application.Index(tabloatutu, , 3))
            'quantité inf 1000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatutu(e2), , 3)) < 1000 Then
                tablo(6, 4) = tablo(6, 4) + 1
                End If
            'quantité 1000/2000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatutu(e2), , 3)) >= 1000 And Application.Min(Application.Index(tabloatutu(e2), , 3)) < 2000 Then
                tablo(6, 5) = tablo(6, 5) + 1
                End If
            'quantité 2000/3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatutu(e2), , 3)) >= 2000 And Application.Min(Application.Index(tabloatutu(e2), , 3)) < 3000 Then
                tablo(6, 6) = tablo(6, 6) + 1
                End If
            'quantité sup 3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatutu(e2), , 3)) >= 3000 Then
                tablo(6, 7) = tablo(6, 7) + 1
                End If
            'calculs la moyenne des mvts concernées et l'écrit dans le tableau de synthese
            tablo(6, 8) = Application.Average(Application.Index(tabloatutu, , 3))
            End If
     
     
            If zone(i, 5) = "toto" Then
            f2 = f2 + 1
            ReDim Preserve tabloatoto(f2)
     
            tabloatoto(f2) = Application.Index(zone, i)
            tablo(8, 1) = f2 'écrit la quantité de départs titi dans le tableau de synthese
            'trouve la valeur min et l'écrit dans le tableau de synthese
            tablo(8, 2) = Application.Min(Application.Index(tabloatoto, , 3))
            'trouve la valeur max et l'écrit dans le tableau de synthese
            tablo(8, 3) = Application.Max(Application.Index(tabloatoto, , 3))
            'quantité inf 1000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatoto(f2), , 3)) < 1000 Then
                tablo(8, 4) = tablo(8, 4) + 1
                End If
            'quantité 1000/2000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatoto(f2), , 3)) >= 1000 And Application.Min(Application.Index(tabloatoto(f2), , 3)) < 2000 Then
                tablo(8, 5) = tablo(8, 5) + 1
                End If
            'quantité 2000/3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatoto(f2), , 3)) >= 2000 And Application.Min(Application.Index(tabloatoto(f2), , 3)) < 3000 Then
                tablo(8, 6) = tablo(8, 6) + 1
                End If
            'quantité sup 3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatoto(f2), , 3)) >= 3000 Then
                tablo(8, 7) = tablo(8, 7) + 1
                End If
            'calculs la moyenne
            tablo(8, 8) = Application.Average(Application.Index(tabloatoto, , 3))
            End If
     
     
            If zone(i, 5) = "LFtyty" Then
            g2 = g2 + 1
            ReDim Preserve tabloatyty(g2)
     
            tabloatyty(g2) = Application.Index(zone, i)
            tablo(10, 1) = g2
            'trouve la valeur min et l'écrit dans le tableau de synthese
            tablo(10, 2) = Application.Min(Application.Index(tabloatyty, , 3))
            'trouve la valeur max et l'écrit dans le tableau de synthese
            tablo(10, 3) = Application.Max(Application.Index(tabloatyty, , 3))
            'quantité inf 1000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatyty(g2), , 3)) < 1000 Then
                tablo(10, 4) = tablo(10, 4) + 1
                End If
            'quantité 1000/2000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatyty(g2), , 3)) >= 1000 And Application.Min(Application.Index(tabloatyty(g2), , 3)) < 2000 Then
                tablo(10, 5) = tablo(10, 5) + 1
                End If
            'quantité 2000/3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatyty(g2), , 3)) >= 2000 And Application.Min(Application.Index(tabloatyty(g2), , 3)) < 3000 Then
                tablo(10, 6) = tablo(10, 6) + 1
                End If
            'quantité sup 3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatyty(g2), , 3)) >= 3000 Then
                tablo(10, 7) = tablo(10, 7) + 1
                End If
            'calculs la moyenne
            tablo(10, 8) = Application.Average(Application.Index(tabloatyty, , 3))
            End If
     
     
            If zone(i, 5) = "tgtg" Then
            h2 = h2 + 1
            ReDim Preserve tabloatgtg(h2)
     
            tabloatgtg(h2) = Application.Index(zone, i)
            tablo(12, 1) = h2 '
            'trouve la valeur min et l'écrit dans le tableau de synthese
            tablo(12, 2) = Application.Min(Application.Index(tabloatgtg, , 3))
            'trouve la valeur max et l'écrit dans le tableau de synthese
            tablo(12, 3) = Application.Max(Application.Index(tabloatgtg, , 3))
            'quantité inf 1000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatgtg(h2), , 3)) < 1000 Then
                tablo(12, 4) = tablo(12, 4) + 1
                End If
            'quantité 1000/2000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatgtg(h2), , 3)) >= 1000 And Application.Min(Application.Index(tabloatgtg(h2), , 3)) < 2000 Then
                tablo(12, 5) = tablo(12, 5) + 1
                End If
            'quantité 2000/3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatgtg(h2), , 3)) >= 2000 And Application.Min(Application.Index(tabloatgtg(h2), , 3)) < 3000 Then
                tablo(12, 6) = tablo(12, 6) + 1
                End If
            'quantité sup 3000 et l'écrit dans le tableau de synthese
                If Application.Min(Application.Index(tabloatgtg(h2), , 3)) >= 3000 Then
                tablo(12, 7) = tablo(12, 7) + 1
                End If
            'calculs la moyenne
            tablo(12, 8) = Application.Average(Application.Index(tabloatgtg, , 3))
            End If
     
    Next i
    Merci

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

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

    Informations forums :
    Inscription : Octobre 2016
    Messages : 1 703
    Par défaut
    Au lieu de passer par du code VBA, ne pourrais-tu pas faire un tableau croisé dynamique?
    Et même si tu dois passer par du code VBA, la création de TCD en VBA ne serait-elle pas plus simple?

  7. #7
    Expert éminent
    Avatar de Marc-L
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2013
    Messages
    9 468
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2013
    Messages : 9 468
    Par défaut
    Bonjour !

    Citation Envoyé par nouveauvba Voir le message
    Est il possible de créer une variable tableau avec une partie fixe de son nom et une partie variable?
    Différentes possibilités indirectes mais en voyant le code initial c'est carrément superfétatoire !
    (A défaut d'une présentation initiale enfin digne de ce nom, claire & complète, avec tenants & aboutissants …)

    A partir du code présenté initialement juste via l'ordre d'une matrice :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
             R = [{"A4:A20","C4:C20"}]
         ReDim T(1 To UBound(R))
        For N& = 1 To UBound(R)
          T(N) = Range("Feuil2!" & R(N)).Value
        Next
    ___________________________________________________________________________________________________________
    Je suis Paris, Egypte, Stockholm, London, Istanbul, Berlin, Nice, Bruxelles, Charlie, …

Discussions similaires

  1. Savoir exploiter une variable tableau avec une sous variable tableau
    Par patricktoulon dans le forum Général JavaScript
    Réponses: 9
    Dernier message: 03/02/2016, 22h26
  2. Réponses: 2
    Dernier message: 28/09/2010, 19h00
  3. [PHP 5.0] instancier une classe avec son nom dans une variable
    Par Nnay_ dans le forum Langage
    Réponses: 1
    Dernier message: 12/02/2009, 12h49
  4. affichage d'un tableau avec des colonnes fixes
    Par jbaudens dans le forum C
    Réponses: 3
    Dernier message: 28/10/2007, 19h31
  5. Réponses: 7
    Dernier message: 23/08/2006, 15h59

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