ComboBox won't match selection if I type more than 1 char

EighterFromDecatur

New Member
Joined
Aug 27, 2011
Messages
2
VBA newbie here, using Excel 2010. I have a named range containing employees, which I'm populating in a drop-down list on a user form. Occasionally I need to enter a non-employee's name, so I'm trying to use a combo box. In the user form, I expect to be able to type multiple characters until Excel finds an unambiguous match. It's matching on one character but not multiple characters -- even when there's truly a match. Sample data in the combo box is:
Simpson, Ann
Smith, Andrew
Snyder, Marge
Stewart, Bob
If I type "S", it will match the first entry and jump to "Simpson, Ann", but if I type a second character that should match ("Sm," "Sn" or "St"), it quits matching. Here's the code that initializes the combo box, which seems to work fine:

Private Sub UserForm_Initialize()
Dim rng As Range
Dim empl As Variant
Set empl = Worksheets("Sheet1").Range("Employees")
For Each empl In rng
ComboBox1.AddItem empl.Value
Next empl
End Sub

Here are the what I believe are the relevant properties on the ComboBox1 control.
ListStyle = 0 - fmListStylePlain
MatchEntry = 1 - fmMatchEntryComplete
MatchRequired = False
Style = 0 - fmStyleDropDownCombo

Any ideas?
 
Last edited:

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Your code should be this...

Code:
Private Sub UserForm_Initialize()
Dim rng As Range
Dim empl As Range
Set [COLOR="Red"]rng[/COLOR] = Worksheets("Sheet1").Range("Employees")
For Each empl In rng
ComboBox1.AddItem empl.Value
Next empl
End Sub

Or something like this...
Code:
Private Sub UserForm_Initialize()
    ComboBox1.RowSource = "Sheet1!" & Worksheets("Sheet1").Range("Employees").Address
End Sub

Otherwise, it worked for me.
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,134
Members
452,890
Latest member
Nikhil Ramesh

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