listbox

  • Thread starter Thread starter x taol
  • Start date Start date
X

x taol

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top