![]() |
listbox
A userform have a listbox and a textbox. There are many lists in the listbox. example, 1403, 1405,......2005 i want to focus on the list of listbox when i input the specific list name to the textbox. ex) If I input 2000 in the textbox, the 2000 is selected and then focusing on the location. my code is following: Private Sub txtHo_Change() If Len(Me.txtHo) < 4 Then Exit Sub With Me.ListBox1 For i = 0 To .ListCount - 1 If .List(i) = CLng(txtHo) Then For k = 0 To .ListCount - 1 .Selected(k) = False Next .Selected(i) = True ''' here is code need End If Next End With End Sub *** Sent via Developersdex http://www.developersdex.com *** |
listbox
Private Sub txtHo_Change()
If Len(Me.txtHo.Value) < 4 Then Exit Sub On Error GoTo invalid_value Me.ListBox1.Value = Me.txtHo.Value Exit Sub invalid_value: Beep End Sub HTH -- AP "x taol" a écrit dans le message de news: ... A userform have a listbox and a textbox. There are many lists in the listbox. example, 1403, 1405,......2005 i want to focus on the list of listbox when i input the specific list name to the textbox. ex) If I input 2000 in the textbox, the 2000 is selected and then focusing on the location. my code is following: Private Sub txtHo_Change() If Len(Me.txtHo) < 4 Then Exit Sub With Me.ListBox1 For i = 0 To .ListCount - 1 If .List(i) = CLng(txtHo) Then For k = 0 To .ListCount - 1 .Selected(k) = False Next .Selected(i) = True ''' here is code need End If Next End With End Sub *** Sent via Developersdex http://www.developersdex.com *** |
All times are GMT +1. The time now is 08:59 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com