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 :

[Macro] Insertion automatique


Sujet :

Macros et VBA Excel

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Octobre 2010
    Messages
    7
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2010
    Messages : 7
    Par défaut [Macro] Insertion automatique
    Bonjour,

    Avant de m'exposer le problème, je suis content de retrouver sur ce forum. Je cherchais un forum/site pour découvrir le langage VBA.

    Au lieu de télécharger un logiciel de la gestion, j'ai préféré de faire par moi-même une base de données avec le classeur Excel.
    Tout s'est bien passé. J'ai créé 2 feuilles: la page d'accueil et la base de données. J'ai crée un bouton d'insertion, dans la page d'accueil, qui permet d'insérer les données dans la seconde feuille (base de donnée). Ca fonctionne bien. Il insère les données dans la première ligne.

    Sauf que j'ai un petit soucis. Au lieu de passer à la ligne suivante, il écrase la première ligne. J'ai surement dû oublier d'activer la feuille. Comment peut-on faire?

    Voici les codes:

    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
    Private Bdocument As Boolean, Bnumero As Boolean, Bobjet As Boolean, Bdate As Boolean, Bsupport As Boolean, Bemplacement As Boolean, Bproduit As Boolean, Bmotcle As Boolean, Btype As Boolean, Bsoustype As Boolean, Bfamille As Boolean, Bmodele1 As Boolean, Bzf As Boolean
    Private i As Integer
     
    Private Sub Annuler_Click()
        End
    End Sub
     
    Private Sub ComboBoxModele1_Change()
        Select Case ComboBoxFamille.Value
        Case 1 'Arriel
            Case 1 '1
            Case 1 '2
        Case 2 'Arrius
             Case 1 '1
             Case 2 '2
        Case 3 'TM 333
        Case 4 'Makila
             Case 1 '1
             Case 2 '2
        Case 5 'Ardiden
              Case 1 '1
              Case 3 '3
        Case 6 'MTR 390
        Case 7 'RTM 322
        Case 8 'Ancien génération
        Case 9 'Démonstrateur
        Case 10 'SNECMA
        Case 11 'Concurence
            Case 4 'Pratt & Whitney
            Case 5 'Autres
            Bmodele1 = True
        End Select
    End Sub
     
    Private Sub ComboBoxMotCle_Click()
        Select Case ComboBoxProduit.Value
        Case 1  'Réducteur
            Select Case ComboBoxMotCle.Value
                Case 1 ' Arbre
                Case 2 ' Couple mètre
            End Select
        End Select
        Select Case ComboBoxProduit.Value
        Case 2  'Turbine
            Select Case ComboBoxMotCle.Value
                Case 3 'Turbine HP
            ComboBoxType.AddItem "Stator"                          'Index =  1
            ComboBoxType.AddItem "Rotor"                           'Index =  2
            ComboBoxType.AddItem "Carter"                          'Index =  3
                Case 4 'Turbine Libre
            ComboBoxType.AddItem "Stator"                          'Index = 1
            ComboBoxType.AddItem "Rotor"                           'Index = 2
            ComboBoxType.AddItem "Carter"                          'Index = 3
            ComboBoxType.AddItem "Blindage"                        'Index = 4
                Case 5 'Ejection et Tuyère
                Case 6 'ZF Etanchéité gaz
                Case 7 'ZF Jeux
            ComboBoxType.AddItem "Jeux axiaux"                     'Index = 1
            ComboBoxType.AddItem "Jeux radiaux"                    'Index = 2
                Case 8 'ZF Veine aérodynamique
            End Select
            End Select
        Select Case ComboBoxProduit.Value
        Case 3  'Composants communs
            Select Case ComboBoxMotCle.Value
                Case 9 'Palier
            ComboBoxType.AddItem "Boîtier"                        'Index = 1
            ComboBoxType.AddItem "Element d'assemblage"       'Index = 2
            ComboBoxType.AddItem "Roulement"                      'Index = 2
            ComboBoxType.AddItem "ZF Lubrification"           'Index = 3
            ComboBoxType.AddItem "ZF Amortissement"               'Index = 4
                Case 10 'Joints & étanchéité
            ComboBoxType.AddItem "Statique"                       'Index = 1
            ComboBoxType.AddItem "Dynamique"                  'Index = 2
                Case 11 'Structure
            ComboBoxType.AddItem "Fixation"                       'Index = 1
            ComboBoxType.AddItem "Blindage"                   'Index = 2
            ComboBoxType.AddItem "Element de liaison"         'Index = 3
            ComboBoxType.AddItem "Carénage"                   'Index = 4
                Case 12 'Pièces d'assemblage
                Case 13 'Transport levage
                Case 14 'ZF Interface cellule
            End Select
            End Select
        Select Case ComboBoxProduit.Value
        Case 4  'Systèmes
            Select Case ComboBoxMotCle.Value
                 Case 15 'Système d'huiles
            ComboBoxType.AddItem "Tuyauteries"                 'Index = 1
            ComboBoxType.AddItem "Circuit de pression"        'Index = 2
            ComboBoxType.AddItem "Circuit de récupérage"      'Index = 3
            ComboBoxType.AddItem "Circuit de dégazage"        'Index = 4
                Case 16 'Circuit d'air
            ComboBoxType.AddItem "Tuyauteries"
                Case 17 'Système électrique
            ComboBoxType.AddItem "Capteur"                    'Index = 1
            ComboBoxType.AddItem "Vitesse et Couple"          'Index = 2
            ComboBoxType.AddItem "Température"                'Index = 3
                Case 18 'Système de drainage
            ComboBoxType.AddItem "Drain tuyère"                   'Index = 18
            ComboBoxType.AddItem "Receptacles"                'Index = 18
            End Select
            End Select
            Bmotcle = True
    End Sub
     
    Private Sub ComboBoxProduit_Click()
        Select Case ComboBoxProduit.Value
        Case 1 'Réducteur
            ComboBoxMotCle.AddItem "Arbre"          'ListIndex = 1
            ComboBoxMotCle.AddItem "Couple mètre"   'ListIndex = 2
        Case 2 'Turbine
            ComboBoxMotCle.AddItem "Turbine HP"                 'ListIndex = 3
            ComboBoxMotCle.AddItem "Turbine Libre"              'ListIndex = 4
            ComboBoxMotCle.AddItem "Ejection et Tuyère"         'ListIndex = 5
            ComboBoxMotCle.AddItem "ZF Etanchéité"              'ListIndex = 6
            ComboBoxMotCle.AddItem "ZF Jeux"                    'ListIndex = 7
            ComboBoxMotCle.AddItem "ZF Veine aérodynamique"     'ListIndex = 8
        Case 3 'Composants communs
        ComboBoxMotCle.AddItem "Palier"                         'ListIndex = 9
        ComboBoxMotCle.AddItem "Joints & étanchéité"            'ListIndex = 10
        ComboBoxMotCle.AddItem "Structure"                      'ListIndex = 11
        ComboBoxMotCle.AddItem "Pièces d'assemblages"           'ListIndex = 12
            ComboBoxMotCle.AddItem "Transport levage"            'ListIndex = 13
            ComboBoxMotCle.AddItem "ZF Interface cellule"        'ListIndex = 14
        Case 4 'Systèmes
        ComboBoxMotCle.AddItem "Système d'huile"                 'ListIndex = 15
        ComboBoxMotCle.AddItem "Circuit d'air"                   'ListIndex = 16
        ComboBoxMotCle.AddItem "Système électrique"              'ListIndex = 17
        ComboBoxMotCle.AddItem "Systèmes de drainage"            'ListIndex = 18
        Bproduit = True
    End Select
    End Sub
     
    Private Sub ComboBoxSousType_Change()
        Select Case ComboBoxProduit.Value
        Case 1  'Réducteur
             Select Case ComboBoxMotCle.Value
                    Case 1 'Arbre
                    Case 2 'Couple mètre
                End Select
        Case 2 'Turbine
            Case 3 'Turbine HP
                Select Case ComboBoxType.Value
                Case 1 'Stator
                Select Case ComboBoxSousType.Value
                    Case 1 'Distributeur
                    Case 2 'Enveloppe
                    End Select
                Case 2 'Rotor
                    Select Case ComboBoxSousType.Value
                    Case 3 'Pale
                    Case 4 'Disque
                    Case 5 'Attache
                    End Select
                Case 3 'Carter
                End Select
            Case 4 'Turbine Libre
                Select Case ComboBoxType.Value
                Case 4 'Stator
                Case 5 'Rotor
                    Select Case ComboBoxSousType.Value
                    Case 6 'Pale
                    Case 7 'Disque
                    Case 8 'Attache
                    End Select
                Case 6 'Carter
                Case 7 'Blindage
                End Select
            Case 5 'Ejection & Tuyère
            Case 6 'ZF Etanchéité gaz
            Case 7 'ZF Jeux
                Select Case ComboBoxType.Value
                Case 8 'Jeux axiaux
                Case 9 'Jeux radiaux
                End Select
            Case 8 'ZF Veine aérodynamique
        Case 3 'composant communs
            Case 9 'Palier
                Select Case ComboBoxType.Value
                Case 10 'Boîtier
                Case 11 'Element d'assemblage
                Case 12 'Roulement
                Case 13 'ZF Lubrification
                Case 14 'ZF Amortissement
                End Select
            Case 10 'Joints & Etanchéité
                Select Case ComboBoxType.Value
                Case 15 'Statique
                Case 16 'Dynamique
                Select Case ComboBoxSousType.Value
                    Case 9 'Labyrinthe
                    Case 10 'Joint radiaux
                    Case 11 'Joint faciaux
                    End Select
                End Select
            Case 11 'Structure
                Select Case ComboBoxType.Value
                Case 17 'Fixation
                Case 18 'Blindage
                Case 19 'Element de liaison
                Case 20 'Carénage
                End Select
            Case 12 'Pièces d'assemblage
            Case 13 'Transport levage
            Case 14 'ZF Interface cellule
        Case 4 'Système
            Case 15 'Système d'huile
                Select Case ComboBoxType.Value
                Case 21 'Tuyauteries
                Case 22 'Circuit de pression
                Case 23 'Circuit de récupérage
                Case 24 'Circuit de dégazage
                End Select
            Case 16 'Circuit d'air
                Select Case ComboBoxType.Value
                Case 25 'Tuyauteries
                End Select
            Case 17 'Système électrique
                Select Case ComboBoxType.Value
                Case 26 'Capteurs
                Case 27 'Vitesse et Couple
                Case 28 'Température
                End Select
            Case 18 'Système de drainage
                Select Case ComboBoxType.Value
                Case 29 'Drain tuyère
                Case 30 'Receptacles
                End Select
                 Bsoustype = True
        End Select
    End Sub
     
    Private Sub ComboBoxType_Click()
        Select Case ComboBoxProduit.Value
        Case 1  'Réducteur
             Select Case ComboBoxMotCle.Value
                    Case 1 'Arbre
                    Case 2 'Couple mètre
                End Select
        Case 2 'Turbine
            Case 3 'Turbine HP
                Select Case ComboBoxType.Value
                Case 1 'Stator
                    ComboBoxSousType.AddItem "Distributeur"            'Index = 1
                    ComboBoxSousType.AddItem "Enveloppe"               'Index = 1
                Case 2 'Rotor
                    ComboBoxSousType.AddItem "Pale"                    'Index = 2
                    ComboBoxSousType.AddItem "Disque"                  'Index = 2
                    ComboBoxSousType.AddItem "Attache"                 'Index = 2
                Case 3 'Carter
                End Select
            Case 4 'Turbine Libre
                Select Case ComboBoxType.Value
                Case 4 'Stator
                Case 5 'Rotor
                    ComboBoxSousType.AddItem "Pale"                    'Index = 5
                    ComboBoxSousType.AddItem "Disque"                  'Index = 5
                    ComboBoxSousType.AddItem "Attache"                 'Index = 5
                Case 6 'Carter
                Case 7 'Blindage
                End Select
            Case 5 'Ejection & Tuyère
            Case 6 'ZF Etanchéité gaz
            Case 7 'ZF Jeux
                Select Case ComboBoxType.Value
                Case 8 'Jeux axiaux
                Case 9 'Jeux radiaux
                End Select
            Case 8 'ZF Veine aérodynamique
        Case 3 'composant communs
            Case 9 'Palier
                Select Case ComboBoxType.Value
                Case 10 'Boîtier
                Case 11 'Element d'assemblage
                Case 12 'Roulement
                Case 13 'ZF Lubrification
                Case 14 'ZF Amortissement
                End Select
            Case 10 'Joints & Etanchéité
                Select Case ComboBoxType.Value
                Case 15 'Statique
                Case 16 'Dynamique
                    ComboBoxSousType.AddItem "Labyrinthe"              'Index = 16
                    ComboBoxSousType.AddItem "Joint radiaux"           'Index = 16
                    ComboBoxSousType.AddItem "Joint faciaux"           'Index = 16
                End Select
            Case 11 'Structure
                Select Case ComboBoxType.Value
                Case 17 'Fixation
                Case 18 'Blindage
                Case 19 'Element de liaison
                Case 20 'Carénage
                End Select
            Case 12 'Pièces d'assemblage
            Case 13 'Transport levage
            Case 14 'ZF Interface cellule
        Case 4 'Système
            Case 15 'Système d'huile
                Select Case ComboBoxType.Value
                Case 21 'Tuyauteries
                Case 22 'Circuit de pression
                Case 23 'Circuit de récupérage
                Case 24 'Circuit de dégazage
                End Select
            Case 16 'Circuit d'air
                Select Case ComboBoxType.Value
                Case 25 'Tuyauteries
                End Select
            Case 17 'Système électrique
                Select Case ComboBoxType.Value
                Case 26 'Capteurs
                Case 27 'Vitesse et Couple
                Case 28 'Température
                End Select
            Case 18 'Système de drainage
                Select Case ComboBoxType.Value
                Case 29 'Drain tuyère
                Case 30 'Receptacles
                End Select
                 Btype = True
        End Select
    End Sub
     
    Private Sub Insérer_Click()
    If Bdocument = True And Bnumero = True _
        And Bobjet = True And Bdate = True And Bsupport = True _
        And Bemplacement = True And Bproduit = True And Bmotcle = True _
        And Btype = True And Bsoustype = True And Bfamille = True _
        And Bmodele1 = True And Bzf = True Then
            Application.ScreenUpdating = False
            CalculLigne
            Sheets("BASE de DONNEES").Range("A" & i).Value = ListBoxDocument.List(ListBoxDocument.ListIndex)
            Sheets("BASE de DONNEES").Range("B" & i).Value = TextBoxNumero.Value
            Sheets("BASE de DONNEES").Range("C" & i).Value = TextBoxObjet.Value
            Sheets("BASE de DONNEES").Range("D" & i).Value = TextBoxDate.Value
            Sheets("BASE de DONNEES").Range("E" & i).Value = ListBoxSupport.List(ListBoxSupport.ListIndex)
            Sheets("BASE de DONNEES").Range("F" & i).Value = TextBoxEmplacement.Value
            Sheets("BASE de DONNEES").Range("G" & i).Value = ComboBoxProduit.Value
            Sheets("BASE de DONNEES").Range("H" & i).Value = ComboBoxMotCle.Value
            Sheets("BASE de DONNEES").Range("I" & i).Value = ComboBoxType.Value
            Sheets("BASE de DONNEES").Range("J" & i).Value = ComboBoxSousType.Value
            Sheets("BASE de DONNEES").Range("K" & i).Value = ComboBoxFamille.Value
            Sheets("BASE de DONNEES").Range("L" & i).Value = ComboBoxModele1.Value
            Sheets("BASE de DONNEES").Range("M" & i).Value = TextBoxZF.Value
        Else
            GestionInsertion
        End If
    End Sub
     
    Private Sub CalculLigne()
        For i = 6 To Range("D65536").End(xlUp).Row
            If Sheets("BASE de DONNEES").Cells(i, 1).Value = "" Then
                Exit For
            End If
        Next i
    End Sub
     
    Private Sub ListBoxDocument_Change()
        If ListBoxDocument.ListIndex <> -1 Then
            Bdocument = True
        End If
    End Sub
     
    Private Sub TextBoxNumero_Change()
        If TextBoxNumero.Value <> "" Then
            Bnumero = True
        End If
    End Sub
     
    Private Sub TextBoxObjet_Change()
        If TextBoxObjet.Value <> "" Then
            Bobjet = True
        End If
    End Sub
     
    Private Sub TextBoxDate_Change()
        If TextBoxDate.Value <> "" Then
            Bdate = True
        End If
    End Sub
     
    Private Sub ListBoxSupport_Change()
        If ListBoxSupport.ListIndex <> -1 Then
            Bsupport = True
        End If
    End Sub
     
    Private Sub TextBoxEmplacement_Change()
        If TextBoxEmplacement.Value <> "" Then
            Bemplacement = True
        End If
    End Sub
     
    Private Sub ComboBoxFamille_Click()
        Select Case ComboBoxFamille.Value
        Case 1 'Arriel
            ComboBoxModele1.AddItem "1"                        'ListIndex = 1
            ComboBoxModele1.AddItem "2"                        'ListIndex = 2
        Case 2 'Arrius
             ComboBoxModele1.AddItem "1"                        'ListIndex = 1
             ComboBoxModele1.AddItem "2"                        'ListIndex = 2
        Case 3 'TM 333
        Case 4 'Makila
             ComboBoxModele1.AddItem "1"                        'ListIndex = 1
             ComboBoxModele1.AddItem "2"                        'ListIndex = 2
        Case 5 'Ardiden
              ComboBoxModele1.AddItem "1"                        'ListIndex = 1
              ComboBoxModele1.AddItem "3"                        'ListIndex = 3
        Case 6 'MTR 390
        Case 7 'RTM 322
        Case 8 'Ancien génération
        Case 9 'Démonstrateur
        Case 10 'SNECMA
        Case 11 'Concurence
            ComboBoxModele1.AddItem "Pratt & Whitney"          'ListIndex = 4
            ComboBoxModele1.AddItem "Autres"                   'ListIndex = 5
        End Select
        Bfamille = True
    End Sub
     
    Private Sub TextBoxZF_Change()
        If TextBoxZF.Value <> "" Then
            Bzf = True
        End If
    End Sub
     
    Private Sub UserForm_Initialize()
        i = 6
        'Initialisation des booléens
        Bdocument = False
        Bnumero = False
        Bobjet = False
        Bdate = False
        Bsupport = False
        Bemplacement = False
        Bproduit = False
        Bmotcle = False
        Btype = False
        Bsoustype = False
        Bfamille = False
        Bmodele1 = False
        Bzf = False
        'Création des choix de la listbox Document
        ListBoxDocument.AddItem "Note Technique"
        ListBoxDocument.AddItem "Plan et Dessin"
        ListBoxDocument.AddItem "Revue"
        ListBoxDocument.AddItem "Photo et Architecture"
        ListBoxDocument.AddItem "Compte-rendu"
        'Création des choix de la listbox Support
        ListBoxSupport.AddItem "DVD"
        ListBoxSupport.AddItem "CD"
        ListBoxSupport.AddItem "Papier"
        ListBoxSupport.AddItem "Livre"
        ListBoxSupport.AddItem "Dossier"
        ListBoxSupport.AddItem "Fichier Informatisé"
        'Création des choix de la combox Produit
        ComboBoxProduit.AddItem "Réducteurs"              'ListIndex = 1
        ComboBoxProduit.AddItem "Turbine"                 'ListIndex = 2
        ComboBoxProduit.AddItem "Composants communs"      'ListIndex = 3
        ComboBoxProduit.AddItem "Systèmes"                'ListIndex = 4
        'Création des choix de la combox MotCle
        ComboBoxMotCle.AddItem "Arbre"                      'Index = 1
        ComboBoxMotCle.AddItem "Couple mètre"               'Index = 1
        ComboBoxMotCle.AddItem "Turbine HP"                 'Index = 2
        ComboBoxMotCle.AddItem "Turbine Libre"              'Index = 2
        ComboBoxMotCle.AddItem "Ejection et Tuyère"         'Index = 2
        ComboBoxMotCle.AddItem "ZF Etanchéité"              'Index = 2
        ComboBoxMotCle.AddItem "ZF Jeux"                    'Index = 2
        ComboBoxMotCle.AddItem "ZF Veine aérodynamique"     'Index = 2
        ComboBoxMotCle.AddItem "Palier"                     'Index = 3
        ComboBoxMotCle.AddItem "Joints et Etanchéité"       'Index = 3
        ComboBoxMotCle.AddItem "Structure"                  'Index = 3
        ComboBoxMotCle.AddItem "Pièces d'assemblage"        'Index = 3
        ComboBoxMotCle.AddItem "Transport levage"           'Index = 3
        ComboBoxMotCle.AddItem "ZF Interface cellule"       'Index = 3
        ComboBoxMotCle.AddItem "Système d'huile"            'Index = 4
        ComboBoxMotCle.AddItem "Circuit d'air"              'Index = 4
        ComboBoxMotCle.AddItem "Système électrique"         'Index = 4
        ComboBoxMotCle.AddItem "Système de drainage"        'Index = 4
        'Création des choix de la combox Type
        ComboBoxType.AddItem "Stator"                     'Index = 2
        ComboBoxType.AddItem "Rotor"                      'Index = 2
        ComboBoxType.AddItem "Carter"                     'Index = 2
        ComboBoxType.AddItem "Stator"                     'Index = 2
        ComboBoxType.AddItem "Rotor"                      'Index = 2
        ComboBoxType.AddItem "Carter"                     'Index = 2
        ComboBoxType.AddItem "Blindage"                   'Index = 2
        ComboBoxType.AddItem "Jeux axiaux"                'Index = 2
        ComboBoxType.AddItem "Jeux radiaux"               'Index = 2
        ComboBoxType.AddItem "Boîtier"                    'Index = 3
        ComboBoxType.AddItem "Element d'assemblage"       'Index = 3
        ComboBoxType.AddItem "Roulement"                  'Index = 3
        ComboBoxType.AddItem "ZF Lubrification"           'Index = 3
        ComboBoxType.AddItem "ZF Amortissement"           'Index = 3
        ComboBoxType.AddItem "Statique"                   'Index = 3
        ComboBoxType.AddItem "Dynamique"                  'Index = 3
        ComboBoxType.AddItem "Fixation"                   'Index = 3
        ComboBoxType.AddItem "Blindage"                   'Index = 3
        ComboBoxType.AddItem "Element de liaison"         'Index = 3
        ComboBoxType.AddItem "Carénage"                   'Index = 3
        ComboBoxType.AddItem "Tuyauteries"                'Index = 4
        ComboBoxType.AddItem "Circuit de pression"        'Index = 4
        ComboBoxType.AddItem "Circuit de récupérage"      'Index = 4
        ComboBoxType.AddItem "Circuit de dégazage"        'Index = 4
        ComboBoxType.AddItem "Tuyauteries"                'Index = 4
        ComboBoxType.AddItem "Capteur"                    'Index = 4
        ComboBoxType.AddItem "Vitesse et Couple"          'Index = 4
        ComboBoxType.AddItem "Température"                'Index = 4
        ComboBoxType.AddItem "Drain tuyère"               'Index = 4
        ComboBoxType.AddItem "Receptacles"                'Index = 4
        'Création des choix de la combox Sous-type
        ComboBoxSousType.AddItem "Distributeur"            'Index = 1
        ComboBoxSousType.AddItem "Enveloppe"               'Index = 2
        ComboBoxSousType.AddItem "Pale"                    'Index = 2
        ComboBoxSousType.AddItem "Disque"                  'Index = 2
        ComboBoxSousType.AddItem "Attache"                 'Index = 2
        ComboBoxSousType.AddItem "Pale"                    'Index = 2
        ComboBoxSousType.AddItem "Disque"                  'Index = 2
        ComboBoxSousType.AddItem "Attache"                 'Index = 2
        ComboBoxSousType.AddItem "Labyrinthe"              'Index = 3
        ComboBoxSousType.AddItem "Joint radiaux"           'Index = 3
        ComboBoxSousType.AddItem "Joint faciaux"           'Index = 3
        'création des choix de la combox Famille
        ComboBoxFamille.AddItem "Arriel"                   'ListIndex = 1
        ComboBoxFamille.AddItem "Arrius"                   'ListIndex = 2
        ComboBoxFamille.AddItem "TM333"                    'ListIndex = 3
        ComboBoxFamille.AddItem "Makila"                   'ListIndex = 4
        ComboBoxFamille.AddItem "Ardiden"                  'ListIndex = 5
        ComboBoxFamille.AddItem "MTR390"                   'ListIndex = 6
        ComboBoxFamille.AddItem "RTM322"                   'ListIndex = 7
        ComboBoxFamille.AddItem "Ancien génération"        'ListIndex = 8
        ComboBoxFamille.AddItem "Démonstrateur"            'ListIndex = 9
        ComboBoxFamille.AddItem "SNECMA"                   'ListIndex = 10
        ComboBoxFamille.AddItem "Concurrence"              'ListIndex = 11
        'création des choix de la combox Modele
        ComboBoxModele1.AddItem "1"                        'ListIndex = 1
        ComboBoxModele1.AddItem "2"                        'ListIndex = 2
        ComboBoxModele1.AddItem "3"                        'ListIndex = 3
        ComboBoxModele1.AddItem "Pratt & Whitney"          'ListIndex = 4
        ComboBoxModele1.AddItem "Autres"                   'ListIndex = 5
    End Sub
     
    Private Sub UserForm_Terminate()
        ListBoxDocument.Clear
        ListBoxSupport.Clear
    End Sub
     
    Private Sub GestionInsertion()
        Btype = True
        Bnumero = True
        Bobjet = True
        Bdate = True
        Bsupport = True
        Bemplacement = True
        Bproduit = True
        Bmotcle = True
        Btype = True
        Bsoustype = True
        Bfamille = True
        Bmodele1 = True
        Bzf = True
    End Sub

  2. #2
    Expert confirmé Avatar de jfontaine
    Homme Profil pro
    Contrôleur de Gestion
    Inscrit en
    Juin 2006
    Messages
    4 756
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : France, Sarthe (Pays de la Loire)

    Informations professionnelles :
    Activité : Contrôleur de Gestion

    Informations forums :
    Inscription : Juin 2006
    Messages : 4 756
    Par défaut
    Bonjour,


    Pour connaitre la dernière ligne utilisée, tu peux utiliser l'instruction ci dessous (la Colonne A doit être colonne en saisie obligatoire

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    i= Sheets("Feuille Données").Range("A:A").End(xlDown).Row
    Bon courage

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Octobre 2010
    Messages
    7
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2010
    Messages : 7
    Par défaut
    Merci. Où dois-je le placer? Dans quel ligne?

  4. #4
    Expert confirmé Avatar de jfontaine
    Homme Profil pro
    Contrôleur de Gestion
    Inscrit en
    Juin 2006
    Messages
    4 756
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : France, Sarthe (Pays de la Loire)

    Informations professionnelles :
    Activité : Contrôleur de Gestion

    Informations forums :
    Inscription : Juin 2006
    Messages : 4 756
    Par défaut
    Une méthode :

    1) Tu remplaces ta procedure calculligne par une fonction

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    Function CalculLigne() As Long
     
        CalculLigne = Sheets("feuil4").Range("A:A").End(xlDown).Row + 1
     
    End Function
    2) tu utilises cette fonction dans la procedure insertion
    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
    Private Sub Insérer_Click()
    dim i as long
    
    If Bdocument = True And Bnumero = True _
        And Bobjet = True And Bdate = True And Bsupport = True _
        And Bemplacement = True And Bproduit = True And Bmotcle = True _
        And Btype = True And Bsoustype = True And Bfamille = True _
        And Bmodele1 = True And Bzf = True Then
            Application.ScreenUpdating = False
            i= CalculLigne
            Sheets("BASE de DONNEES").Range("A" & i).Value = ListBoxDocument.List(ListBoxDocument.ListIndex)
            Sheets("BASE de DONNEES").Range("B" & i).Value = TextBoxNumero.Value
            Sheets("BASE de DONNEES").Range("C" & i).Value = TextBoxObjet.Value
            Sheets("BASE de DONNEES").Range("D" & i).Value = TextBoxDate.Value
            Sheets("BASE de DONNEES").Range("E" & i).Value = ListBoxSupport.List(ListBoxSupport.ListIndex)
            Sheets("BASE de DONNEES").Range("F" & i).Value = TextBoxEmplacement.Value
            Sheets("BASE de DONNEES").Range("G" & i).Value = ComboBoxProduit.Value
            Sheets("BASE de DONNEES").Range("H" & i).Value = ComboBoxMotCle.Value
            Sheets("BASE de DONNEES").Range("I" & i).Value = ComboBoxType.Value
            Sheets("BASE de DONNEES").Range("J" & i).Value = ComboBoxSousType.Value
            Sheets("BASE de DONNEES").Range("K" & i).Value = ComboBoxFamille.Value
            Sheets("BASE de DONNEES").Range("L" & i).Value = ComboBoxModele1.Value
            Sheets("BASE de DONNEES").Range("M" & i).Value = TextBoxZF.Value
        Else
            GestionInsertion
        End If
    End Sub

    EDIT : Penses a mettre le nom de ta feuille données a la place de feuil4

  5. #5
    Membre à l'essai
    Profil pro
    Inscrit en
    Octobre 2010
    Messages
    7
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2010
    Messages : 7
    Par défaut
    Merci, j'ai appliqué votre méthode. Et cela ne fonctionne toujours pas.

    Et celui là, il faut le placer aussi?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    i= Sheets("Feuille Données").Range("A:A").End(xlDown).Row

  6. #6
    Expert confirmé Avatar de jfontaine
    Homme Profil pro
    Contrôleur de Gestion
    Inscrit en
    Juin 2006
    Messages
    4 756
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : France, Sarthe (Pays de la Loire)

    Informations professionnelles :
    Activité : Contrôleur de Gestion

    Informations forums :
    Inscription : Juin 2006
    Messages : 4 756
    Par défaut
    Est ce que la colonne A de l 'onglet données a bien une donnée sur chaque ligne

  7. #7
    Membre à l'essai
    Profil pro
    Inscrit en
    Octobre 2010
    Messages
    7
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2010
    Messages : 7
    Par défaut
    Oui. Les données s'insèrent à partir de la ligne 6. Début > Colonne A et ligne 6.

  8. #8
    Expert confirmé Avatar de jfontaine
    Homme Profil pro
    Contrôleur de Gestion
    Inscrit en
    Juin 2006
    Messages
    4 756
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : France, Sarthe (Pays de la Loire)

    Informations professionnelles :
    Activité : Contrôleur de Gestion

    Informations forums :
    Inscription : Juin 2006
    Messages : 4 756
    Par défaut
    Quel est le comportement de la macro maintenant?
    Y a t il une erreur ?

  9. #9
    Membre à l'essai
    Profil pro
    Inscrit en
    Octobre 2010
    Messages
    7
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2010
    Messages : 7
    Par défaut
    Oui. Il écrase la première ligne. Toujours, même avec vos modifications.

  10. #10
    Membre éclairé Avatar de grisan29
    Homme Profil pro
    ouvrier poseur
    Inscrit en
    Octobre 2006
    Messages
    866
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ouvrier poseur
    Secteur : Bâtiment

    Informations forums :
    Inscription : Octobre 2006
    Messages : 866
    Par défaut
    bonjour keke64, jfontaine et le forum

    voici ce que j'utillise
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Sheets("feuil2").Range("a65536").End(xlUp)(2) = TextBox3.Value & " " & TextBox2.Value
    et qui me permet de progresser ligne apres lignes a adapter a ton projet

    cordialement

    Pascal

  11. #11
    Membre à l'essai
    Profil pro
    Inscrit en
    Octobre 2010
    Messages
    7
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2010
    Messages : 7
    Par défaut
    TextBox3.Value & " " & TextBox2.Value
    Cela correspond aux colonnes?

  12. #12
    Expert confirmé Avatar de jfontaine
    Homme Profil pro
    Contrôleur de Gestion
    Inscrit en
    Juin 2006
    Messages
    4 756
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : France, Sarthe (Pays de la Loire)

    Informations professionnelles :
    Activité : Contrôleur de Gestion

    Informations forums :
    Inscription : Juin 2006
    Messages : 4 756
    Par défaut
    Non, cela semble correspondre à la concaténation de 2 textbox

  13. #13
    Membre à l'essai
    Profil pro
    Inscrit en
    Octobre 2010
    Messages
    7
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2010
    Messages : 7
    Par défaut
    Oui. Mais ce que je veux dire il faudra remplacer TextBox3.Value & " " & TextBox2.Value par les noms de Texbox de mon projet.

    C'est ça?

  14. #14
    Expert confirmé Avatar de jfontaine
    Homme Profil pro
    Contrôleur de Gestion
    Inscrit en
    Juin 2006
    Messages
    4 756
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : France, Sarthe (Pays de la Loire)

    Informations professionnelles :
    Activité : Contrôleur de Gestion

    Informations forums :
    Inscription : Juin 2006
    Messages : 4 756
    Par défaut
    Oui. Mais ce que je veux dire il faudra remplacer TextBox3.Value & " " & TextBox2.Value par les noms de Texbox de mon projet.

    C'est ça?
    Oui

  15. #15
    Membre éclairé Avatar de grisan29
    Homme Profil pro
    ouvrier poseur
    Inscrit en
    Octobre 2006
    Messages
    866
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ouvrier poseur
    Secteur : Bâtiment

    Informations forums :
    Inscription : Octobre 2006
    Messages : 866
    Par défaut
    bonjour keke64, jfontaine et le forum

    Non, cela semble correspondre à la concaténation de 2 textbox
    oui cela correspond a la conténation des 2 textbox
    mais il peut s'agir aussi bien 2 combobox
    ils peuvent porter chacun un nom propre au fichier auquel ils appartiennent

    cordialement

    Pascal

Discussions similaires

  1. [VBA-E]insertion automatique d'une ligne dans un tableau
    Par janus82 dans le forum Macros et VBA Excel
    Réponses: 7
    Dernier message: 06/04/2006, 15h42
  2. insertion automatique
    Par vduhaze dans le forum Access
    Réponses: 2
    Dernier message: 01/02/2006, 18h19
  3. Réponses: 1
    Dernier message: 10/01/2006, 18h50
  4. Powerpoint et insertions automatiques
    Par rapathonyk dans le forum Powerpoint
    Réponses: 2
    Dernier message: 24/06/2005, 13h50
  5. insertion automatique de code et d import
    Par benohite dans le forum Eclipse Java
    Réponses: 4
    Dernier message: 17/11/2003, 09h23

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