1 pièce(s) jointe(s)
Remplissage textbox d'après Listbox
Bonjour,
je continu avec mon user form et je rencontre un nouveau problème.
Mes boutons Enregistrer, Effacer, modifier, et quitter fonctionne parfaitement, et ma liste box charge bien en fonction de ce que j'écris dans la textbox affaire. (Je n'ai pas encore fait le bouton supprimer).
Mon problème est que lorsque je charge ma liste box d'après ma text box, et que je clique sur une des lignes de ma list box, les différentes données vont dans les différentes textbox et combobox correspondante. Mais cela mets forcement la dernière ligne de ma liste box. Si je clique sur une nouvelle ligne, rien de ne se passe.
Avec vous une idée ?
Voici mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Private Sub ListBox1_Click()
With ThisWorkbook.Sheets("FACTURATION")
For Each Nom In .Range("=B8:B" & .[B65000].End(xlUp).Row)
If CStr(Nom) = CStr(Me.ListBox1.Value) Then
Me.TextBoxaffaire.Value = .Cells(Nom.Row, 2)
TextBoxbat.Value = .Cells(Nom.Row, 3)
Me.TextBoxchantier.Value = .Cells(Nom.Row, 4)
ComboBoxmatiere.Value = .Cells(Nom.Row, 5)
Me.TextBoxlargeur.Value = .Cells(Nom.Row, 6)
Me.TextBoxhauteur.Value = .Cells(Nom.Row, 7)
Me.TextBoxquantite.Value = .Cells(Nom.Row, 8)
Me.TextBoxm2.Value = .Cells(Nom.Row, 9)
Me.ComboBoxforme.Value = .Cells(Nom.Row, 10)
Me.ComboBoxfinition.Value = .Cells(Nom.Row, 11)
Me.ComboBoxaccessoires.Value = .Cells(Nom.Row, 12)
Me.ComboBoxproduits.Value = .Cells(Nom.Row, 13)
Me.TextBoxcommentaire.Value = .Cells(Nom.Row, 14)
Me.ComboBoxdivers.Value = .Cells(Nom.Row, 15)
Me.TextBoxcoutdivers.Value = .Cells(Nom.Row, 16)
Me.TextBoxcout.Value = .Cells(Nom.Row, 17)
End If
Next
End With
End Sub |
Et le fichiers
Merci à vousPièce jointe 462475