Renvoi a une ligne a partir d'un double clic listbox
Résolu
Raphlight
-
Raphlight -
Raphlight -
Bonjour,
J'ai un fais une fonction recherche (textbox) et les résultats apparaissent dans différentes "listbox"
Jusque là tout vas bien.
mon code actuel :
Ensuite je voudrais pouvoir cliquer sur une ligne de ma listbox et que cela me renvoi a la ligne correspondante dans ma base (juste dessous).
Et je ne vois pas comment faire...
J’espère avoir été assez clair (dans ma tête ce l'est toujours^^)
je vous remercie du dérangement
Cordialement.
J'ai un fais une fonction recherche (textbox) et les résultats apparaissent dans différentes "listbox"
Jusque là tout vas bien.
mon code actuel :
Private Sub TextBox1_Change() 'www.blog-excel.com/creer-un-champ-de-recherche-vba
Application.ScreenUpdating = False
ListBox1.Clear 'Exemple 2 (ListBox)
ListBox2.Clear
ListBox3.Clear
ListBox4.Clear
ListBox5.Clear
ListBox6.Clear
ListBox7.Clear
ListBox8.Clear
If TextBox1 <> "" Then
For ligne = 11 To 10000
If Cells(ligne, 1) Like "*" & TextBox1 & "*" Then
ListBox1.AddItem Cells(ligne, 1) 'Exemple 2 (ListBox)
ListBox2.AddItem Cells(ligne, 2)
ListBox3.AddItem Cells(ligne, 3)
ListBox4.AddItem Cells(ligne, 4)
ListBox5.AddItem Cells(ligne, 5)
ListBox6.AddItem Cells(ligne, 6)
ListBox7.AddItem Cells(ligne, 7)
ListBox8.AddItem Cells(ligne, 8)
End If
Next
End If
End Sub
Ensuite je voudrais pouvoir cliquer sur une ligne de ma listbox et que cela me renvoi a la ligne correspondante dans ma base (juste dessous).
Et je ne vois pas comment faire...
J’espère avoir été assez clair (dans ma tête ce l'est toujours^^)
je vous remercie du dérangement
Cordialement.
A voir également:
- Renvoi a une ligne a partir d'un double clic listbox
- Double ecran - Guide
- Creer un groupe whatsapp a partir d'un autre groupe - Guide
- Whatsapp double sim - Guide
- Comment faire une recherche à partir d'une photo - Guide
- Partager photos en ligne - Guide
4 réponses
Bonjour,
Erreur de compréhension...
Désolé.
En fait, il te faut stocker les numéros des lignes dans une seconde colonne cachée d'une listbox.
Avant, j'arrivais jamais à finir mes phrases... mais maintenant je
Erreur de compréhension...
Désolé.
En fait, il te faut stocker les numéros des lignes dans une seconde colonne cachée d'une listbox.
Avant, j'arrivais jamais à finir mes phrases... mais maintenant je
Bonjour,
cliquer sur une ligne de ma listbox Y a 8 TextBoxs, laquelle allez-vous choisir ???????????????????????????????????
cliquer sur une ligne de ma listbox Y a 8 TextBoxs, laquelle allez-vous choisir ???????????????????????????????????
Re
Quelque chose comme ceci :
Quelque chose comme ceci :
Private Sub TextBox1_Change() 'www.blog-excel.com/creer-un-champ-de-recherche-vba
Application.ScreenUpdating = False
ListBox1.Clear 'Exemple 2 (ListBox)
ListBox1.ColumnCount = 2
ListBox1.ColumnWidths = ListBox1.Width & ";0"
ListBox2.Clear
ListBox2.ColumnCount = 2
ListBox2.ColumnWidths = ListBox2.Width & ";0"
ListBox3.Clear
ListBox3.ColumnCount = 2
ListBox3.ColumnWidths = ListBox3.Width & ";0"
ListBox4.Clear
ListBox4.ColumnCount = 2
ListBox4.ColumnWidths = ListBox4.Width & ";0"
ListBox5.Clear
ListBox5.ColumnCount = 2
ListBox5.ColumnWidths = ListBox5.Width & ";0"
ListBox6.Clear
ListBox6.ColumnCount = 2
ListBox6.ColumnWidths = ListBox6.Width & ";0"
ListBox7.Clear
ListBox7.ColumnCount = 2
ListBox7.ColumnWidths = ListBox7.Width & ";0"
ListBox8.Clear
ListBox8.ColumnCount = 2
ListBox8.ColumnWidths = ListBox8.Width & ";0"
If TextBox1 <> "" Then
For ligne = 11 To 10000
If Cells(ligne, 1) Like "*" & TextBox1 & "*" Then
ListBox1.AddItem Cells(ligne, 1) 'Exemple 2 (ListBox)
ListBox1.List(ListBox1.ListCount - 1, 1) = ligne
ListBox2.AddItem Cells(ligne, 2)
ListBox2.List(ListBox2.ListCount - 1, 1) = ligne
ListBox3.AddItem Cells(ligne, 3)
ListBox3.List(ListBox3.ListCount - 1, 1) = ligne
ListBox4.AddItem Cells(ligne, 4)
ListBox4.List(ListBox4.ListCount - 1, 1) = ligne
ListBox5.AddItem Cells(ligne, 5)
ListBox5.List(ListBox5.ListCount - 1, 1) = ligne
ListBox6.AddItem Cells(ligne, 6)
ListBox6.List(ListBox6.ListCount - 1, 1) = ligne
ListBox7.AddItem Cells(ligne, 7)
ListBox7.List(ListBox7.ListCount - 1, 1) = ligne
ListBox8.AddItem Cells(ligne, 8)
ListBox8.List(ListBox8.ListCount - 1, 1) = ligne
End If
Next
End If
End Sub
Private Sub ListBox1_Click()
MsgBox ListBox1.List(ListBox1.ListIndex, 1)
End Sub
Private Sub ListBox2_Click()
MsgBox ListBox2.List(ListBox2.ListIndex, 1)
End Sub
Private Sub ListBox3_Click()
MsgBox ListBox3.List(ListBox3.ListIndex, 1)
End Sub
Private Sub ListBox4_Click()
MsgBox ListBox4.List(ListBox4.ListIndex, 1)
End Sub
Private Sub ListBox5_Click()
MsgBox ListBox5.List(ListBox5.ListIndex, 1)
End Sub
Private Sub ListBox6_Click()
MsgBox ListBox6.List(ListBox6.ListIndex, 1)
End Sub
Private Sub ListBox7_Click()
MsgBox ListBox7.List(ListBox7.ListIndex, 1)
End Sub
Private Sub ListBox8_Click()
MsgBox ListBox8.List(ListBox8.ListIndex, 1)
End Sub
Avant il me trouvait les résultats avec ou sans majuscule. plus maintenant.
Les lignes de cde que j'ai ajouté ne changent rien à ta recherche...
Tout se fait là :
Pour trouver indiféremment avec ou sans majuscules :
Explications :
====> Largeur Colonne 1 = ListBox1.Width (soit la largeur de la listbox)
====> Largeur colonne 2 = 0 (colonne invisible)
Les lignes de cde que j'ai ajouté ne changent rien à ta recherche...
Tout se fait là :
If Cells(ligne, 1) Like "*" & TextBox1 & "*" Then
Pour trouver indiféremment avec ou sans majuscules :
If UCase(Cells(ligne, 1)) Like "*" & UCase(TextBox1) & "*" Then
Explications :
ListBox1.ColumnCount = 2==> Paramètre la listBox1 en multicolonne avec 2 colonnes
ListBox1.ColumnWidths = ListBox1.Width & ";0"==> règle la largeur des deux colonnes :
====> Largeur Colonne 1 = ListBox1.Width (soit la largeur de la listbox)
====> Largeur colonne 2 = 0 (colonne invisible)
ListBox1.List(ListBox1.ListCount - 1, 1) = ligne==> place le numéro de la ligne dans la colonne 2 de la listbox (colonne 2 = invisible)