How do I place cursor into TextBox or CombBox?

HvyEquipment

New Member
Joined
Apr 19, 2004
Messages
11
Hopefully, this is an easy question:

I have a sequence of textboxes and comboboxes on a userform and I would like to make one of the textboxes active (ie cursor blinking in that textbox ready to accept user input) based upon the combobox selection.

For example:

Combobox1 items = Text1, Text2 & Text3

Select Text2 from the Combobox1 and the cursor needs to move to Text2 and wait on the user to input text.

For whatever reason, I cannot figure out how to do this, can anyway please steer me in the right direction?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

hatman

Well-known Member
Joined
Apr 8, 2005
Messages
2,664
something like this, i would think
Code:
Private Sub ComboBox1_Change()

    Dim item As MSForms.Control

    For Each item In Me.Controls
    
        If item.Name = Me.ComboBox1.Value Then
        
            item.SetFocus
            
        End If
    
    Next item
    

End Sub
 

Forum statistics

Threads
1,141,155
Messages
5,704,626
Members
421,360
Latest member
Rhodia

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
Top