Search Contextures Sites ![]()
Excel Data Validation Combo box using Named Ranges
You can use Excel Data Validation to create a dropdown list of options in a cell. However, the list font can't be changed, nor can the number of visible rows, which has a maximum of eight. Also, Data Validation doesn't have an AutoComplete feature, which finds matching items in the list as you start to type.To overcome these limitations, you can add a combo box to your worksheet, and use programming to make it appear in cells that contain a data validation list. Double-click on a cell that contains a data validation list, and the combo box appears. The combo box's font size can be set, more than 8 rows can be displayed, and autocomplete can be enabled.
Note: If the worksheet is protected, allow users to Edit Objects, and they will be able to use the combobox.
Set up the WorkbookTwo worksheets are required in this workbook.
- Delete all sheets except Sheet1 and Sheet2
- Rename Sheet1 as ValidationSample
- Rename Sheet2 as ValidationLists
On the ValidationLists sheet, type the lists that will be used in the data validation dropdowns:
Tip: Use the AutoFill feature to create the lists
- In cells A1:A7 type a list of weekdays
- In cells C1:C12 type a list of months
Name the lists (there are Naming instructions here: Name a Range):
Create an Excel Data Validation Dropdown ListThe next step is to create the data validation dropdown lists. There are detailed instructions here: Excel Data Validation Introduction
![]()
Add the Combo boxTo add or edit the Combobox, open the Control Toolbox, and enter Design Mode:
Open the Properties WindowTo format the combo box, open the properties window:
- Select the combo box
- On the Control Toolbox, click the Properties button
![]()
Set the Number of Rows
- In the Properties window, click in the ListRows box
- Type the number of rows that you want displayed in the dropdown. In this example, the setting is: 12
Turn on AutoComplete
- In the Properties window, click in the MatchEntry property
- From the dropdown list, select 1-frmMatchEntryComplete
Exit Design Mode
- Close the Properties window
- On the Control Toolbox, click the Exit Design Mode button
To add this code to the worksheet:
Test the Code
- Double-click on one of the cells that contains a data validation list.
- The combo box will appear
- Select an item from the combo box dropdown list
- Click on a different cell, to select it
- The selected item appears in previous cell, and the combo box disappears.
Download the zipped sample file
Excel Tutorials - Data Validation
Contextures Inc., Copyright ©2010
All rights reserved.
Last updated: October 13, 2010 1:19 AM