Tabbing through list boxes

RedJames

Board Regular
Joined
Jun 3, 2014
Messages
67
Hello,

I am creating a form in Excel 2007/XP. I have a series of list boxes that I would like users to be able to tab and type to make selections. Right now when I hit tab (or an arrow key) while in the list box it does nothing. Anyone know if it is possible to tab from one list box to the next?

Thanks!
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
How are you creating the form and listboxes?
 
Upvote 0
I am actually altering a form that was previously created so I'm not excatly sure how it was created, but I am adding using Developer > Insert > Active X > List Box
 
Upvote 0
I am actually altering a form that was previously created so I'm not excatly sure how it was created, but I am adding using Developer > Insert > Active X > List Box
You should be able to do it with the ListBox's KeyDown event. You will have to create one of these for each of your ListBoxes modifying the name of the ListBox to Select. Here is the code for a Tab Key in ListBox1 to select ListBox2...
Code:
Private Sub ListBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
  If KeyCode = vbKeyTab Then ActiveSheet.ListBox2.Select
End Sub
 
Upvote 0
Thanks for your help! I have pasted that code after this "Private Sub ListBox1_Click() End Sub" but I can't get it to work. I looks like it is trying to do something, but only flashes the most recent cell selected. Hitting a key still makes a selection in List Box 1.
 
Upvote 0
Thanks for your help! I have pasted that code after this "Private Sub ListBox1_Click() End Sub" but I can't get it to work. I looks like it is trying to do something, but only flashes the most recent cell selected. Hitting a key still makes a selection in List Box 1.
To tell you the truth, I was only guessing at a solution as I never considered typing into a ListBox... the beauty of that control is point-and-click with the mouse (which can then be repeated for any ListBox in any order). Anyway, to still try and help you with the question you asked... I guess my main question is how is your user getting into the ListBox in order to type anything? And what code is in your ListBox Click event?
 
Upvote 0
Right now I am just clicking into the first list box. The form is a series of list boxes and text entry fields. The reason I am trying to enable typing is that half of the users prefer to tab and type and the other half prefer to click. Currently there is no code in the click event. I assume this is because all of the instructions have been done through properties.
 
Upvote 0
The weird thing is it was allowing me to tab through when using form list boxes, but it would not allow a selection to be typed. With Active X, it will select by using the first letter typed, but will not tab. aaargh
 
Upvote 0
I am not sure why, but my code does not work in the KeyDown event, but it does seem to work from the KeyUp event. Again, for ListBox1 to tab over to ListBox2...

Code:
Private Sub ListBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
  If KeyCode = vbKeyTab Then
    Me.ListBox2.Activate
  End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,222,653
Messages
6,167,370
Members
452,111
Latest member
NyVmex

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top