Validate Entries in Excel Combo Box

One of my Excel sample files lets you double-click on a cell that has a data validation list, and a combo box pops up. The combo box has advantages, because you can set the font size, and the number of rows in the drop down list, and the entry autocompletes as you type.

However, one of the disadvantages is that the combo box lets you type anything, even if it’s not a valid entry from the data validation list. In the combo box shown below, I was able to type “Cold” as a month name.

And even though there are several cold months in Canada, there isn’t one that’s officially named “Cold”.

If I tried to enter “Cold” in the worksheet cell where the data validation list is, an error message would appear, and the entry wouldn’t be allowed.

Set the Combo Box Properties

In an ideal world, the combo box would prevent me from entering an invalid item. It has a Match Required property, and I have that set to True.

However, as the Excel Help so helpfully points out, “Not all containers enforce this property.” Unfortunately, the worksheet is one of those non-enforcing containers.

Change the Combo Box Style

Because the MatchRequired property doesn’t work, you can change the Combo Box Style property, to prevent people from typing non-list entries. We’ll select List style, which doesn’t allow freeform typing.

In my sample file, the combo box is only visible when you double-click on a data validation cell. To make a change to the combo box properties, follow these steps:

Double-click on a data validation cell, to show the combo box.

On the Developer tab, click the Design Mode command.

Click on the combo box border, to select it, and click Properties, on the Developer tab.

In the Properties window, scroll down to the Style property, and select 2- fmStyleDropDownList.

Close the Properties window, and click the Design Mode command again, to turn that setting off.

Test the Combo Box

To test the revised combo box

Double-click on a data validation cell.

In the combo box, try to type an invalid entry, such as “Cold”

The entry doesn’t appear, because it’s not in the list. In the screen shot below, you can see the result when I tried typing Cold – it defaulted to January, the first item in the list.

14 Responses

I opened the sample xlsm file and got some strange behavior in Excel 2010. When I double-click on one of the DV cells I can barely see a combobox between columns B and C. If I then go into Design Mode and expand it (strangely, it expands to about 100 rows) and then double-click one of the data validation cells, all of the comboboxes assume the right size and position.

Thanks for this excellent idea and explanation.
I found a possibility to enter *wrong* values into the cell when using double-clicked combobox.
When using simple data validation, then this is not possible.
Any room for improvements?

Thanks for this excellent idea and explanation.
I found a possibility to enter wrong values into the cell when using double-clicked combobox.
When using simple data validation, then this is not possible.
Any room for improvements?

Thanks Debra for this ! As usual, your tip is just GREAT and actually so usefull ! Just a small problem with numeric validation list as combo box transfers values to the linked cell as text: it makes problem if this cell is referenced as numeric in formula etc…

One workaround I tried is to use an intermediate cell with the validation and multiply the value of the intermediate cell by 1 in the original cell…

It works but I have still problem when using it combined with worksheet_change …

It would be nice if a vba workaround could deal with this problem of conversion from comb box, but I haven’t yet found it. Any idea?

Debra I downloaded your zip file for validating data with a combo box (it looks perfect in your video), but I do not see the effects of the code on my machine. I see the 8-item list without the autocomplete feature. Is there an additional setting in 2010 that I need?

I figured out my problem. I had copied your code into my worksheet and modified it (incorrectly) for my purposes. Then when I downloaded your code, it appears that mine had precedence. When I removed my copy, your spreadsheet worked correctly.

I’m implementing a combo box with validation but have a layout problem. When I double click and the combo box appears, it is too narrow. You can see both the combo dropdown and, slightly to the right, the validation drop down. This behavior occurs even if I change the width of the combo box entries – the combo dropdown has the set width, but the top most cell of the combo box is still to narrow. Any ideas? I downloaded the sample but don’t see any differences between it and mine.