Most Excel users probably believe that a VBA macro is required in order to display a drop-down list in a cell. But it’s not. You can easily display a drop-down list in a cell, no macros required. Figure: 1 shows an example. Cell B2, when selected, displays a down arrow. Click the arrow, and you get a list of items (in this case, month names). Click an item, and it appears in the cell. The drop-down list can contain text, numeric values, or dates. Your formulas, of course, can refer to cells that contain a drop-down list. The formulas always use the value that’s currently displayed.
The trick to setting up a drop-down list is to use the data validation feature. The following steps describe how to create a drop-down list of items in a cell:
- Enter the list of items in a range. In this example, the month names are in the range E1:E12.
- Select the cell that will contain the drop-down list (cell B2, in this example).
- Choose Data➜Data Tools➜Data Validation.
- In the Data Validation dialog box, click the Settings tab.
- In the Allow drop-down list, select List.
- In the Source box, specify the range that contains the items. In this example, the range is E1:E12.
- Make sure that the In-Cell Dropdown option is checked (see Figure 2) and click OK.
Note: If your list is short, you can avoid Step 1. Rather, just type your list items (separated by commas) in the Source box in the Data Validation dialog box.
In previous versions, the list of items were required to be on the same worksheet as the cell that contains the drop-down list. With Excel 2010, that’s no longer the case. If you plan to share your workbook with others who use an older version of Excel, make sure that the list is on the same sheet as the drop-down list. Alternatively, you can put the list on any sheet, as long as it’s a named range. For example, you can choose Formulas. Defined Names. Define Name to define the name MonthNames for E1:E12. Then, in the Data Validation dialog box, enter = MonthNames in the Source box.