Excel 2019 Bible

(singke) #1

Chapter 45: Using UserForm Controls in a Worksheet


45


ListBox
A ListBox control presents a list of items, and the user can select an item (or multiple
items). It’s similar to a ComboBox. The main difference is that a ListBox doesn’t require
you to click a drop-down arrow to display more than one item at a time.

The following is a description of the most useful properties of a ListBox control:

BoundColumn If the list contains multiple columns, this property determines which col-
umn contains the returned value.
ColumnCount This specifies the number of columns to display in the list.
IntegralHeight This is TRUE if the height of the ListBox adjusts automatically to
display full lines of text when the list is scrolled vertically. If FALSE, the ListBox may
display partial lines of text when it’s scrolled vertically.
LinkedCell This specifies the worksheet cell that displays the selected item.
ListFillRange This specifies the worksheet range that contains the list items.
ListStyle This determines the appearance of the list items.
MultiSelect This determines whether the user can select multiple items from the list.

If you use a MultiSelect ListBox, you can’t specify a LinkedCell; you need to write a macro to determine
which items are selected.


OptionButton
OptionButton controls are useful when the user needs to select from a small number of
items. OptionButton controls are always used in groups of at least two.

The following are the most useful properties of an OptionButton control:

Accelerator A letter that lets the user select the option by using the keyboard. For
example, if the accelerator for an OptionButton is C, pressing Alt+C selects the control.
GroupName A name that identifies an OptionButton as being associated with other
OptionButtons with the same GroupName property.
LinkedCell The worksheet cell that’s linked to the OptionButton. The cell displays
TRUE if the control is selected or FALSE if the control isn’t selected.

If your worksheet contains more than one set of OptionButton controls, you must ensure that each set of
OptionButtons has a different GroupName property. Otherwise, all OptionButtons become part of the
same set.

Free download pdf