Monday, January 28, 2008

How to Create a List Box in an Excel Worksheet

Many people use list boxes within forms. Another use of the list box is within an Excel worksheet. This post explains how to add and populate a list box as well as how to refer to the output so that it can be used however you please.

  1. Add a list box to your worksheet anywhere you want it.
  2. Make sure that you are in control edit mode (click the symbol with the pencil and the ruler to the far left of the control toolbar- when edit mode is turned on, when you mouse over the list box, you will be able to click and drag the list box and should not be able to select any of the items within the list box)
  3. Right click the list box (while it is in edit mode)
  4. Click "properties"
  5. Make sure the MultiSelect Property is set to 0 - fmMultiSelectSingle
  6. On the ListFillRange, type in the range which you want the list box to display. For example, If you want to type in the values you want displayed in the list box in Cells A1 through A10, type A1:A10
  7. Set the LinkedCell property to the cell in which you want the output display. For example, if you want the output displayed in cell A11, type A11 in this box.
  8. Turn off the control edit mode (click the symbol with the pencil and the ruler to the far left of the control toolbar)
Now you can use the list box and the value of the selection will be put in your desired output cell!

The above example is only useful when you allow the user to select a single item from the list box. In cases where you want the user to be able to select multiple items (as often is the case) you must use VBA. For my next post, I will provide some VBA code to output multiple selected data.

No comments: