Bonjour à toutes et à tous,
Je viens vers vous afin de trouver une solution ou une aide.
Voilà ma problématique. J'ai un tableau de 4 colonnes. Dans ces colonnes, j'ai une multitude de récurrences. Je cherche à alimenter une listbox à sélection multiples en fonction d'un critère dans une combobox. J'arrive à avoir le résultat pour une ligne, mais pas pour toutes les lignes du tableau. Je sais faire pour une ligne en fait.. C'est l'adaptation à plusieurs lignes où je coince.
Voici mon code :
Pouvez vous m'aider afin de trouver la solution pour toutes les lignes ? Merci d'avance.
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 Dim f, ligneEnreg Private Sub UserForm_Initialize() Set f = Sheets("BD") Set mondico = CreateObject("Scripting.Dictionary") For Each c In Range(f.[A2], f.[A65000].End(xlUp)) mondico(c.Value) = "" Next c Me.ComboBox1.List = mondico.keys Set mondico2 = CreateObject("Scripting.Dictionary") For Each n In Range(f.[C2], f.[C65000].End(xlUp)) mondico2(n.Value) = "" Next n Me.ListBox1.List = mondico2.keys End Sub Private Sub ComboBox1_Click() ligneEnreg = Sheets("BD").[A:A].Find(ComboBox1, LookIn:=xlValues).Row temp = f.Cells(ligneEnreg, 3) a = Split(temp, "") For j = 0 To Me.ListBox1.ListCount - 1: Me.ListBox1.Selected(j) = False: Next j If UBound(a) >= 0 Then For j = 0 To Me.ListBox1.ListCount - 1 If Not IsError(Application.Match(Me.ListBox1.List(j), a, 0)) Then Me.ListBox1.Selected(j) = True Else Me.ListBox1.Selected(j) = False End If Next j End If End Sub
P.S : Si besoin d'un fichier simple sans macro, je peux vous le fournir.
Partager