Moving from cell to combo bo

clunes7

New Member
Joined
Feb 23, 2021
Messages
3
Office Version
  1. 2011
Platform
  1. Windows
Hi Guys
I need some help if possible. I would like some code that would move from a cell E6 to a combo box attached to cell c8 by pushing the tab or enter key so that i can start typing and the combo box is active. Is this possible.
Cheers clayton
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
To install the code...
  • Right-click on the sheet tab
  • Select View Code from the pop-up context menu
  • Paste the code from below in the worksheet's code module
  • Change the ComboBox1 reference in the code to the name of your combobox if different.

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Static Target_Was_E6 As Boolean
    If Target_Was_E6 Then Me.ComboBox1.Activate
    Target_Was_E6 = Target.Address(0, 0) = "E6"
End Sub
 
Last edited:
Upvote 0
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Static Target_Was_E6 As Boolean If Target_Was_E6 Then Me.ComboBox1.Activate Target_Was_E6 = Target.Address(0, 0) = "E6" End Sub
To install the code...
  • Right-click on the sheet tab
  • Select View Code from the pop-up context menu
  • Paste the code from below in the worksheet's code module
  • Change the ComboBox1 reference in the code to the name of your combobox if different.

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Static Target_Was_E6 As Boolean
    If Target_Was_E6 Then Me.ComboBox1.Activate
    Target_Was_E6 = Target.Address(0, 0) = "E6"
End Sub
Thank you so much for this code but if you could help further that would be much appreciated. How can I add to this code so that the sequence continues from e8 to c10 and e10 to c12 etc. I have 20 combo boxes that I would like to jump to.
Thanks again for your time
Clayton
 
Upvote 0
Add more Case lines of code as needed.

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Static Target_Was As String
    Select Case Target_Was
        Case "E6": Me.ComboBox1.Activate
        Case "E8": Me.ComboBox2.Activate
        Case "E10": Me.ComboBox3.Activate
        Case "E12": Me.ComboBox4.Activate
    End Select
    Target_Was = Target.Address(0, 0)
End Sub
 
Upvote 0
Add more Case lines of code as needed.

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Static Target_Was As String
    Select Case Target_Was
        Case "E6": Me.ComboBox1.Activate
        Case "E8": Me.ComboBox2.Activate
        Case "E10": Me.ComboBox3.Activate
        Case "E12": Me.ComboBox4.Activate
    End Select
    Target_Was = Target.Address(0, 0)
End Sub
Awesome thank you so much
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,836
Members
449,096
Latest member
Erald

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