It's simple to introduce the 'enter' selection method.
I'ts also very easy to comment out the 'automatic selection' option:
Code:Private Sub UserForm_Initialize() Left = Application.Left + (0.5 * Application.Width) - (0.5 * Width) Top = Application.Top + (0.5 * Application.Height) - (0.5 * Height) For Each sh In Sheets If sh.Visible Then ListBox1.Tag = ListBox1.Tag & "_" & sh.Name Next End Sub Private Sub UserForm_Activate() ListBox1.List = Split(Mid(ListBox1.Tag, 2), "_") End Sub Private Sub TextBox1_Change() ListBox1.List = Filter(Split(Mid(ListBox1.Tag, 2), "_"), TextBox1.Text) If ListBox1.ListCount = 1 Then M_select End Sub Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 40 And ListBox1.ListCount > 1 Then ListBox1.SetFocus ListBox1.ListIndex = 0 End If End Sub Private Sub ListBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 37 Then TextBox1.SetFocus ListBox1.ListIndex = -1 ElseIf KeyCode = 13 Then M_select End If End Sub Private Sub ListBox1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) M_select End Sub Sub M_select() Sheets(ListBox1.List(ListBox1.ListIndex)).Activate Hide End Sub




Reply With Quote
Bookmarks