XL 2013 listbox , textbox, vba

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

Romaricbienvenu

XLDnaute Nouveau
bonjour la communauté,
j'ai un un soucis avec mon formulaire, j'ai effectué une recherche à partir de ma textbox pour afficher le resultat dans ma listbox et j'aimerai lorsque que je clique sur une ligne dans ma listbox que les données de cette ligne soient renvoyées dans des textboxs.

j'ai essayé et j'ai pas pu

vous savez m'aidez??

je vous dépose mon ficher

merci
 

Pièces jointes

Solution
Bonjour Romaric
Bonjour François
Une adaptation du Code de François, avec le tri demandé Lol
VB:
Private Sub TextBox19_Change()
  Dim i As Long, x As Long, p As Long
  Dim Tbl
  Set Tbl = Nothing
  With Me
      .ListBox1.Clear
      If .TextBox19 = Empty Then Exit Sub
   If Not Range("t_BDD").ListObject.DataBodyRange Is Nothing Then
     With Range("t_BDD").ListObject.DataBodyRange
     Set rng1 = Range("t_BDD").ListObject.ListColumns("Prix (euros)").Range
    Application.ScreenUpdating = False
            With Range("t_BDD").ListObject.Sort
                .SortFields.Clear
                .SortFields.Add Key:=rng1, Order:=xlAscending
                .Header = xlYes
                .Apply
            End With...
Bonjour Romaric
Bonjour François
Une adaptation du Code de François, avec le tri demandé Lol
VB:
Private Sub TextBox19_Change()
  Dim i As Long, x As Long, p As Long
  Dim Tbl
  Set Tbl = Nothing
  With Me
      .ListBox1.Clear
      If .TextBox19 = Empty Then Exit Sub
   If Not Range("t_BDD").ListObject.DataBodyRange Is Nothing Then
     With Range("t_BDD").ListObject.DataBodyRange
     Set rng1 = Range("t_BDD").ListObject.ListColumns("Prix (euros)").Range
    Application.ScreenUpdating = False
            With Range("t_BDD").ListObject.Sort
                .SortFields.Clear
                .SortFields.Add Key:=rng1, Order:=xlAscending
                .Header = xlYes
                .Apply
            End With
    Application.ScreenUpdating = True
        Tbl = .Value
          For i = 1 To UBound(Tbl, 1)
              If UCase(Tbl(i, 1)) Like UCase("*" & Me.TextBox19 & "*") Then
                With Me.ListBox1
                 .AddItem Tbl(i, 1)
                 .List(ListBox1.ListCount - 1, 1) = Tbl(i, 3)
                 .List(ListBox1.ListCount - 1, 2) = Tbl(i, 4)
                 .List(ListBox1.ListCount - 1, 3) = Tbl(i, 6)
                 .List(ListBox1.ListCount - 1, 4) = Tbl(i, 7)
                 .List(ListBox1.ListCount - 1, 5) = Tbl(i, 8)
                 .List(ListBox1.ListCount - 1, 6) = Tbl(i, 9)
                 .List(ListBox1.ListCount - 1, 7) = Tbl(i, 10)
                End With
              End If
          Next i
     End With
  End If
  End With
End Sub
Jean marie
 
Bonjour Romaric
Bonjour François
Une adaptation du Code de François, avec le tri demandé Lol
VB:
Private Sub TextBox19_Change()
  Dim i As Long, x As Long, p As Long
  Dim Tbl
  Set Tbl = Nothing
  With Me
      .ListBox1.Clear
      If .TextBox19 = Empty Then Exit Sub
   If Not Range("t_BDD").ListObject.DataBodyRange Is Nothing Then
     With Range("t_BDD").ListObject.DataBodyRange
     Set rng1 = Range("t_BDD").ListObject.ListColumns("Prix (euros)").Range
    Application.ScreenUpdating = False
            With Range("t_BDD").ListObject.Sort
                .SortFields.Clear
                .SortFields.Add Key:=rng1, Order:=xlAscending
                .Header = xlYes
                .Apply
            End With
    Application.ScreenUpdating = True
        Tbl = .Value
          For i = 1 To UBound(Tbl, 1)
              If UCase(Tbl(i, 1)) Like UCase("*" & Me.TextBox19 & "*") Then
                With Me.ListBox1
                 .AddItem Tbl(i, 1)
                 .List(ListBox1.ListCount - 1, 1) = Tbl(i, 3)
                 .List(ListBox1.ListCount - 1, 2) = Tbl(i, 4)
                 .List(ListBox1.ListCount - 1, 3) = Tbl(i, 6)
                 .List(ListBox1.ListCount - 1, 4) = Tbl(i, 7)
                 .List(ListBox1.ListCount - 1, 5) = Tbl(i, 8)
                 .List(ListBox1.ListCount - 1, 6) = Tbl(i, 9)
                 .List(ListBox1.ListCount - 1, 7) = Tbl(i, 10)
                End With
              End If
          Next i
     End With
  End If
  End With
End Sub
Jean marie
Merci bcoup il marche nickel
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
22
Affichages
937
Réponses
40
Affichages
2 K
Retour