Bonjour à tous
Objectif : quand je sélectionne 210V01 dans ListBox2, la ListBox3 affichera toute les feuilles du classeur (ThisWorkbook.Sheets) qui contient *210V01*
Information :
- Pour afficher l’Userform : feuilles: (BDD equipements) bouton Chercher ou ajouter équipement, Ecrire 210V01 dans TextBox2
- A l’ouverture UserForm3 il y a ce code qui me permit de lister les feuilles dans la feuille (listing), qui fonctionne très bien :
- Voici le code pour la recherche et alimenter la ListBox3, le résultat ne correspond pas à litem sélectionner dans la ListBox2 :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 Private Sub UserForm_Activate() Application.ScreenUpdating = False With Worksheets("listing").Range("E2:E60000") .ClearContents End With Dim i As Integer For i = 1 To Sheets.Count Worksheets("listing").Cells(1 + i, 5) = Sheets(i).Name Next i Application.ScreenUpdating = True 'Facultatif End Sub
Je vous remercie infiniment pour votre attention
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 Private Sub ListBox2_Click() If ListBox2.ListIndex <> -1 Then CommandButton16.Enabled = True Dim Prem As String Dim c As Range With Me.ListBox3 .Clear .ColumnCount = 2 .BoundColumn = 2 .ColumnWidths = "0;160" End With If Me.ListBox2 <> "" Then With Worksheets("listing").Range("E2:E65536") Set c = .Find(Me.ListBox2.ListIndex, LookIn:=xlValues, Lookat:=xlPart) If Not c Is Nothing Then Prem = c.Address Do With Me.ListBox3 .AddItem c.Row .List(.ListCount - 1, 1) = c.Offset(, 5 - c.Column) End With Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address <> Prem End If End With '... End If End Sub
Partager