Problème ajout combobox

patoq

XLDnaute Occasionnel
Bonjour le forum,

Je viens vers vous car j'ai un petit soucis concernant le remplissage d'un combobox.

Dans le fichier joint, le remplissage du combo se passe très bien ; cependant si j'ajoute une catégorie dans la cellule C4, le résultat est "louche" (je me retrouve avec un "blanc" entre les 2 premiers items du combo).

Voici mon fichier et merci pour l'aide que vous m'apporterez.

Cdt
 

Pièces jointes

  • test.xlsm
    28.4 KB · Affichages: 31
  • test.xlsm
    28.4 KB · Affichages: 34
  • test.xlsm
    28.4 KB · Affichages: 33

laetitia90

XLDnaute Barbatruc
Re : Problème ajout combobox

bonjour patoq
2 methode parmi tant d'autres
la premiere basique

Dim c As Range
For Each c In Range("c4:c" & Cells(Rows.Count, 3).End(xlUp).Row)
ComboBox1 = c
If ComboBox1.ListIndex = -1 And ComboBox1 <> "" Then ComboBox1.AddItem c
Next c

avec un dico
Dim c As Variant, m As Object
Set m = CreateObject("Scripting.Dictionary")
For Each c In Range("c4:c" & Cells(Rows.Count, 3).End(xlUp).Row)
If Not m.Exists(c.Value) And c <> "" Then m.Add c.Value, c.Value
Next c
ComboBox1.List = m.Items
 

Discussions similaires

Réponses
3
Affichages
295

Statistiques des forums

Discussions
313 344
Messages
2 097 336
Membres
106 916
dernier inscrit
Soltani mohamed