XL 2019 alimenter les textbox depuis une sélection dans un listbox

le___destin

XLDnaute Occasionnel
bonsoir de le monde
je besoin d'aide
J'ai déjà réussi à faire la recherche et le filtre depuis un userform
mais pas a afficher les information dans des textbox
merci d'avance pour m'aider
 

Pièces jointes

  • test.xlsm
    48.3 KB · Affichages: 15

le___destin

XLDnaute Occasionnel
je reussi a faire ce code sauf que la recherche est par la premier lettre du mot .. j'aime que la recherche soit par compare si le mot contient ce qui saisi dan la textbox27
Code:
Private Sub CommandButton1_Click()
If TextBox2.Value <> "" Then
Worksheets("Noms").Activate
lr = Range("A" & Rows.Count).End(xlUp).Row
Range("A" & lr + 1).Value = TextBox1.Value
Range("A" & lr + 1).Offset(0, 1).Value = TextBox2.Value
Range("A" & lr + 1).Offset(0, 2).Value = TextBox3.Value
Range("A" & lr + 1).Offset(0, 3).Value = TextBox4.Value
Range("A" & lr + 1).Offset(0, 4).Value = TextBox5.Value
Range("A" & lr + 1).Offset(0, 5).Value = TextBox6.Value
Range("A" & lr + 1).Offset(0, 6).Value = TextBox7.Value

TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
TextBox7.Value = ""
Unload Me
Départements.Show
Else

MsgBox (" Vérifier vos informations ")
End If
End Sub

Private Sub CommandButton2_Click()
Worksheets("Noms").Activate
On Error Resume Next
If MsgBox("voulez-vous supprimer les informations suivantes", vbYesNo) = vbYes Then
Rows([B2:B1000].Find(TextBox2.Value).Row).EntireRow.Delete
Unload Me
bopMonastir.Show

End If

End Sub

Private Sub CommandButton3_Click()
Sheets("Noms").Activate
For X = 2 To 2000
If Cells(X, 1) = TextBox1.Text Then
Cells(X, 1).Select
Exit For
End If
Next X
ActiveCell.Offset(0, 1) = TextBox2.Text
ActiveCell.Offset(0, 2) = TextBox3.Text
ActiveCell.Offset(0, 3) = TextBox4.Text
ActiveCell.Offset(0, 4) = TextBox5.Text
ActiveCell.Offset(0, 5) = TextBox6.Text
ActiveCell.Offset(0, 6) = TextBox7.Text
Unload Me
bopMonastir.Show
End Sub

Private Sub CommandButton4_Click()
Unload Me
Application.Visible = True
Worksheets("Noms").Activate
End Sub



Private Sub Image2_BeforeDragOver(ByVal Cancel As MSForms.ReturnBoolean, ByVal Data As MSForms.DataObject, ByVal X As Single, ByVal Y As Single, ByVal DragState As MSForms.fmDragState, ByVal Effect As MSForms.ReturnEffect, ByVal Shift As Integer)

End Sub

Private Sub Image3_BeforeDragOver(ByVal Cancel As MSForms.ReturnBoolean, ByVal Data As MSForms.DataObject, ByVal X As Single, ByVal Y As Single, ByVal DragState As MSForms.fmDragState, ByVal Effect As MSForms.ReturnEffect, ByVal Shift As Integer)

End Sub

Private Sub Label10_Click()

End Sub

Private Sub Image1_BeforeDragOver(ByVal Cancel As MSForms.ReturnBoolean, ByVal Data As MSForms.DataObject, ByVal X As Single, ByVal Y As Single, ByVal DragState As MSForms.fmDragState, ByVal Effect As MSForms.ReturnEffect, ByVal Shift As Integer)

End Sub

Private Sub Label14_Click()

End Sub

Private Sub Label7_Click()

End Sub

Private Sub Label8_Click()

End Sub

Private Sub Label9_Click()

End Sub

Private Sub ListBox1_Click()
For i = 0 To ListBox1.ListCount
    If ListBox1.Selected(i) = True Then
        For j = 1 To 7
        Controls("TextBox" & j).Text = Cells(ListBox1.List(i, 1), j)
        Next j
    End If
Next i
End Sub

Private Sub TextBox1_Change()

End Sub

Private Sub TextBox2_Change()

End Sub



Private Sub TextBox27_Change()
ListBox1.Clear
Worksheets("Noms").Activate
    For i = 1 To 7
            Controls("TextBox" & i).Text = ""
    Next i
    If TextBox27 = "" Then Exit Sub
    ss = Sheets("Noms").Cells(Rows.Count, 2).End(xlUp).Row
     k = 0
For Each c In Range("B2:B" & ss)
    If c Like TextBox27.Value & "*" Then
        ListBox1.AddItem
        ListBox1.List(k, 0) = Cells(c.Row, 2).Value
        ListBox1.List(k, 1) = c.Row
        k = k + 1
    End If
Next c


End Sub

Private Sub TextBox3_Change()

End Sub

Private Sub TextBox4_Change()

End Sub

Private Sub TextBox5_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Worksheets("Noms").Activate
TextBox27.Value = ""
ListBox1.Clear
End Sub

Private Sub TextBox6_Change()

End Sub

Private Sub TextBox7_Change()

End Sub

Private Sub UserForm_Activate()
TextBox27.SetFocus
Worksheets("Noms").Activate
For i = 2 To Sheets("Noms").Cells(Rows.Count, 2).End(xlUp).Row
ListBox1.AddItem
 ListBox1.List(i - 2, 0) = Cells(i, 2).Value
  ListBox1.List(i - 2, 1) = i
  Worksheets("Noms").Activate
      Next i
End Sub
 

ChTi160

XLDnaute Barbatruc
Bonjour le____destin
Bonjour le Fil ,le Forum
Ce que j'ai mis et qui semble fonctionner!
j'ai considérais que dans ta Base , il n'y a pas de Doublon (si doublon dis le moi !) et on reviendra au Dictionaire .
VB:
Private Sub TextBox27_Change()
   Set d1 = CreateObject("Scripting.Dictionary")
  With Me
    With .ListBox1
       .ColumnCount = 1
       .ColumnWidths = "1"
       .Clear
    End With
   tmp = IIf(.TextBox27 = Empty, "*", "*" & UCase(.TextBox27) & "*")
     For i = 1 To UBound(a, 1)
       If UCase(a(i, 1)) Like tmp Then d1(a(i, 1)) = CStr(a(i, 1))
     Next i
      .ListBox1.List = d1.keys
  End With
End Sub

Jean marie
 

le___destin

XLDnaute Occasionnel
bonsoir le forum
bonsoir tout le monde
bonsoir Jean marie et merci pour tout vos aide
je teste ce code mais malheureusement toujours mem problème
désole si je te gène et merci d'avance
 

Pièces jointes

  • teste weh.xlsm
    53.1 KB · Affichages: 4

ChTi160

XLDnaute Barbatruc
Bonjour le____destin
Bonjour le Fil ,le forum
je constate en effet que lors de l'ouverture du userform ("master") ,j'ai le message suivant au niveau de cette Ligne :
Worksheets("Noms").Activate
ce qui veut dire que la feuille "Noms" n'existe pas .
a voir donc !
dis moi ce qui ne a pas chez moi la recherche se fait normalement ......
si je tape "A" tout les mot qui contiennent un "A" sont affichés
si Je tape "AB" seul les mots qui contiennent "AB" remplacent les mots qui ne contenaient que "A"
j'attends ton retour .
jean marie
 

le___destin

XLDnaute Occasionnel
bonsoirs
oui c'est ça .. si je tab
si je tape "A" tout les mot qui contiennent un "A" sont affichés
si Je tape "AB" seul les mots qui contiennent "AB" remplacent les mots qui ne contenaient que "A"
 

Pièces jointes

  • 1591912093157.png
    1591912093157.png
    123.7 KB · Affichages: 4
  • teste weh.xlsm
    53.1 KB · Affichages: 7

Discussions similaires

Réponses
8
Affichages
299

Statistiques des forums

Discussions
311 720
Messages
2 081 907
Membres
101 836
dernier inscrit
karmon