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.

datavalcombovalid01

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.

datavalcombovalid02

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.

datavalcombovalid04

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.

datavalcombovalid09

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.

datavalcombovalid10

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.
    • datavalcombovalid05
  • Click on the combo box border, to select it, and click Properties, on the Developer tab.
    • datavalcombovalid06
  • In the Properties window, scroll down to the Style property, and select 2- fmStyleDropDownList.
    • datavalcombovalid07
  • 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.

datavalcombovalid08

Download the Sample File

To see the data validation combo box, and change its properties, you can download the sample file from my Contextures website – Data Validation Combo Box Named Ranges.

___________

8 comments to Validate Entries in Excel Combo Box

  • Debra,

    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.

  • Hugo

    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?

  • Hugo

    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?

  • Philippe

    Hello,

    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?

  • Cathy

    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?

    • Cathy

      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.

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>