Issue with ComboBox

Rocky0201

Active Member
Joined
Aug 20, 2009
Messages
278
Hi.

I have a ComboBox (ComboBox36) that I wish to use two ways if possible.

First, The user can select a value from the dropdown list. Once the value is selected, the code runs and acts on the selection.

Second, the user can enter data into the ComboBox. Once the enter key is press, the code runs and acts on the value entered.

I've tried the following to no avail.

Private Sub ComboBox36_Change()

Run Code

End Sub

Private Sub ComboBox36_AfterUpdate()

Run Code

End Sub

In the above example, I can select "ABC" from the dropdown and the Change event runs and ABC is diplayed in the ComboBox. If I change ABC to XYZ, the moment I change A to X the Change events runs again.

I guess I'm looking to make the changes in the ComboBox , press enter and the AfterUpdate Event would run.

If I did away with the Change Event and only use the AfterUpdate Event, I can still select ABC from the dropdown but the event does not run.

Am I trying to do something that is not possible?

Thanks.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
This will react to the user either selecting from the list or typing in a value and pressing return. Changing the focus in the Click event is the VBA equivalent of the user pressing enter.
Code:
Private Sub ComboBox1_AfterUpdate()
    Me.Caption = ComboBox1.Text
    Rem call routine
End Sub

Private Sub ComboBox1_Click()
    TextBox1.SetFocus
End Sub
 
Upvote 0
Thank you both!!!

GTO - Yes, it is a UserForm in fact it is my Page 2 of Mulitpage.

mikerickson - The routine seems to work. I did change TextBox1 to ComboBox1 in the Click Event.

Thanks again...
 
Upvote 0

Forum statistics

Threads
1,216,373
Messages
6,130,239
Members
449,568
Latest member
mwl_y

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