Shorter VBA Code for tabbing through multiple ComboBox

ThatsEarElephant

New Member
Joined
Dec 27, 2016
Messages
14
I need to TAB through a combination of ComboBox(es) and cells in my worksheet. I have written the following code to jump from a ComboBox to a ComboBox:

Code:
Private Sub ComboBox1_KeyDown (ByValKeyCode As MSForms.ReturnInteger, ByVal Shift as Integer)
If KeyCode = 9 Then ComboBox2.Activate
End Sub
I also write a code to jump from a CELL to a ComboBox (in some places it is needed). Looks like this:

Code:
Private Sub Worksheet_Change(ByVal TargetAsRange)
If Target.Address = "$A$1" Then
ActiveSheet.ComboBox1.Activate
End If
End Sub

When you put these two codes side-by-side, you can imagine jumping from Cell A1, to Combobox1, to Combobox2. Well, I have a column from D9 to D208 with 5 ComboBoxes next to each cell, and I need to flow through them all by hitting TAB. I've ended up typing it out manually, but is there a way to make one short command which will loop through all of these without writing 2000+ lines of code?

Also, any input on TabStop property of a combobox? Maybe there's a simpler solution



<tbody>
</tbody>
 
Last edited:

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Upvote 0

Forum statistics

Threads
1,196,206
Messages
6,014,011
Members
441,802
Latest member
Aneurysm

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