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 :

combobox sans doublon (colonne de reference avec cellule vide)


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Inscrit en
    Juillet 2007
    Messages
    502
    Détails du profil
    Informations forums :
    Inscription : Juillet 2007
    Messages : 502
    Par défaut combobox sans doublon (colonne de reference avec cellule vide)
    bonjour
    voila un petit probleme.

    mes divers combobox sont remplis sans doublon via le code suivant.
    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
     
    ..........................
     
    'change la couleur des combobox servant à la construction du filtre
    ComboBox24.BackColor = &H80FF80
    ComboBox6.BackColor = &H80FF80
    ComboBox5.BackColor = &H80FF80
    ComboBox26.BackColor = &H80FF80
    ComboBox14.BackColor = &H80FF80
    ComboBox15.BackColor = &H80FF80
    ComboBox16.BackColor = &H80FF80
    ComboBox17.BackColor = &H80FF80
     ComboBox23.BackColor = &H80FF80
    ComboBox22.BackColor = &H80FF80
    ComboBox19.BackColor = &H80FF80
    ComboBox9.BackColor = &H80FF80
    ComboBox8.BackColor = &H80FF80
     ComboBox3.BackColor = &H80FF80
     ComboBox27.BackColor = &H80FF80
    ComboBox29.BackColor = &H80FF80
    ComboBox28.BackColor = &H80FF80
    ComboBox30.BackColor = &H80FF80
    ComboBox4.BackColor = &H80FF80
     
     
                 ComboBox24.AddItem
                 ComboBox6.AddItem
                 ComboBox5.AddItem
                 ComboBox26.AddItem
                 ComboBox14.AddItem
                 ComboBox15.AddItem
                 ComboBox16.AddItem
                 ComboBox17.AddItem
                 ComboBox23.AddItem
                 ComboBox22.AddItem
                 ComboBox19.AddItem
                 ComboBox9.AddItem
                 ComboBox8.AddItem
                 ComboBox3.AddItem
                 ComboBox27.AddItem
                 ComboBox29.AddItem
                 ComboBox28.AddItem
                 ComboBox30.AddItem
                 ComboBox4.AddItem
     
     
     
     
        derniereligne = Sheets("feuil2").Range("A4").End(xlDown).Row 'derniere ligne occupee dans colonne A
     
              For j = 4 To derniereligne
     
               ComboBox24 = Sheets("feuil2").Range("b" & j)
               ComboBox6 = Sheets("feuil2").Range("a" & j)
              ComboBox5 = Sheets("feuil2").Range("d" & j)
              ComboBox26 = Sheets("feuil2").Range("c" & j)
              ComboBox14 = Sheets("feuil2").Range("t" & j)
              ComboBox15 = Sheets("feuil2").Range("u" & j)
              ComboBox16 = Sheets("feuil2").Range("v" & j)
              ComboBox17 = Sheets("feuil2").Range("s" & j)
              ComboBox23 = Sheets("feuil2").Range("i" & j)
              ComboBox22 = Sheets("feuil2").Range("k" & j)
              ComboBox19 = Sheets("feuil2").Range("j" & j)
              ComboBox9 = Sheets("feuil2").Range("p" & j)
              ComboBox8 = Sheets("feuil2").Range("q" & j)
     
              ComboBox3 = Sheets("feuil2").Range("e" & j)
              ComboBox27 = Sheets("feuil2").Range("g" & j)
              ComboBox29 = Sheets("feuil2").Range("ah" & j)
              ComboBox28 = Sheets("feuil2").Range("h" & j)
              ComboBox30 = Sheets("feuil2").Range("ag" & j)
              ComboBox4 = Sheets("feuil2").Range("f" & j)
     
     
     
              If ComboBox24.ListIndex = -1 Then ComboBox24.AddItem Sheets("feuil2").Range("b" & j)
              If ComboBox6.ListIndex = -1 Then ComboBox6.AddItem Sheets("feuil2").Range("a" & j)
              If ComboBox5.ListIndex = -1 Then ComboBox5.AddItem Sheets("feuil2").Range("d" & j)
              If ComboBox26.ListIndex = -1 Then ComboBox26.AddItem Sheets("feuil2").Range("c" & j)
              If ComboBox14.ListIndex = -1 Then ComboBox14.AddItem Sheets("feuil2").Range("t" & j)
              If ComboBox15.ListIndex = -1 Then ComboBox15.AddItem Sheets("feuil2").Range("u" & j)
              If ComboBox16.ListIndex = -1 Then ComboBox16.AddItem Sheets("feuil2").Range("v" & j)
              If ComboBox17.ListIndex = -1 Then ComboBox17.AddItem Sheets("feuil2").Range("s" & j)
              If ComboBox23.ListIndex = -1 Then ComboBox23.AddItem Sheets("feuil2").Range("i" & j)
              If ComboBox22.ListIndex = -1 Then ComboBox22.AddItem Sheets("feuil2").Range("k" & j)
              If ComboBox19.ListIndex = -1 Then ComboBox19.AddItem Sheets("feuil2").Range("j" & j)
              If ComboBox9.ListIndex = -1 Then ComboBox9.AddItem Sheets("feuil2").Range("p" & j)
              If ComboBox8.ListIndex = -1 Then ComboBox8.AddItem Sheets("feuil2").Range("q" & j)
     
              If ComboBox3.ListIndex = -1 Then ComboBox3.AddItem Sheets("feuil2").Range("e" & j)
              If ComboBox27.ListIndex = -1 Then ComboBox27.AddItem Sheets("feuil2").Range("g" & j)
              If ComboBox29.ListIndex = -1 Then ComboBox29.AddItem Sheets("feuil2").Range("ah" & j)
              If ComboBox28.ListIndex = -1 Then ComboBox28.AddItem Sheets("feuil2").Range("h" & j)
              If ComboBox30.ListIndex = -1 Then ComboBox30.AddItem Sheets("feuil2").Range("ag" & j)
              If ComboBox4.ListIndex = -1 Then ComboBox4.AddItem Sheets("feuil2").Range("f" & j)
     
     
     
           Next j
                ComboBox24.ListIndex = 0
                ComboBox6.ListIndex = 0
                ComboBox5.ListIndex = 0
                ComboBox26.ListIndex = 0
                ComboBox14.ListIndex = 0
                ComboBox15.ListIndex = 0
                ComboBox16.ListIndex = 0
                ComboBox17.ListIndex = 0
                ComboBox23.ListIndex = 0
                ComboBox22.ListIndex = 0
                ComboBox19.ListIndex = 0
                ComboBox9.ListIndex = 0
                ComboBox8.ListIndex = 0
     
                ComboBox3.ListIndex = 0
                ComboBox27.ListIndex = 0
                ComboBox29.ListIndex = 0
                ComboBox28.ListIndex = 0
                ComboBox30.ListIndex = 0
                ComboBox4.ListIndex = 0
     
     
     
    ...............................................

    seulement certaine colonne contienne des espaces vide est donc bonjour l'indexation sans doublon

    il y at'il un moyen de palier au cellule vide lors du remplissage de la liste deroulante ????

  2. #2
    Membre éclairé
    Inscrit en
    Juillet 2007
    Messages
    502
    Détails du profil
    Informations forums :
    Inscription : Juillet 2007
    Messages : 502
    Par défaut
    voila j'ai trouve ca
    c'est peut etre pas top

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
     
    ....................
    If ComboBox4.ListIndex = -1 Then If Sheets("feuil2").Range("f" & j) <> "" Then ComboBox4.AddItem Sheets("feuil2").Range("f" & j)
      ..................

    Je teste si la cellule est vide avant item

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

Discussions similaires

  1. Combobox sans doublons
    Par arnold95 dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 21/03/2016, 14h30
  2. [XL-2003] ComboBox Sans Doublon: ça ne marche jamais
    Par Otmanes dans le forum Excel
    Réponses: 2
    Dernier message: 14/07/2009, 11h53
  3. Remplissage de combobox sans doublon
    Par Shadow5 dans le forum Macros et VBA Excel
    Réponses: 7
    Dernier message: 15/04/2008, 20h06
  4. Combobox sans doublon
    Par Psychoze dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 07/03/2008, 19h18
  5. Macro VBA pour mettre colonne en ligne avec cellule fusionnée
    Par dany13 dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 15/01/2008, 06h09

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