ListBox Object

Description

Represents a scrollable list box on the specified chart sheet, dialog sheet, or worksheet. There are three list-box types: single select, simple multi-select, and extended multi-select. The list-box type specifies whether more than one item can be selected from the list, and how multiple items can be selected. For more information, see the MultiSelect property.

You can fill the list either by specifying a range of cells that contains list items (using the ListFillRange property) or by specifying each item (using the AddItem and RemoveItem methods or the List property).

Accessors

The ListBox object is a member of the ListBoxes collection. The ListBoxes collection contains all the ListBox objects on a single sheet. Use the Add method to create a new list box and add it to the collection.

To access a single member of the collection, use the ListBoxes method with the index number or name of the list box as an argument.

The following example sets the list input range for list box two on the worksheet named "Sheet2." When the dialog sheet runs, the contents of cells D1:D15 on the worksheet named "Sheet2" will appear as items in the list box.


Worksheets("sheet2").ListBoxes(2).ListFillRange = "=sheet2!d1:d15"

The list box name is shown in the Name Box when the list box is selected. Use the Name property to set or return the list box name. The following example adds an item to the list shown in the list box named "List Box 2."


Worksheets(1).ListBoxes("list box 2").AddItem "end"

Remarks

On dialog sheets, the LinkCombo method can be used to link a list box and an edit box to create a combination list edit box. For information about combination drop-down edit boxes, see the DropDown object.

Properties

Application Property, BottomRightCell Property, Creator Property, Display3DShading Property, Enabled Property, Height Property, Index Property, Left Property, LinkedCell Property, LinkedObject Property, List Property, ListCount Property, ListFillRange Property, ListIndex Property, Locked Property, MultiSelect Property, Name Property, OnAction Property, Parent Property, Placement Property, PrintObject Property, Selected Property, Top Property, TopLeftCell Property, Value Property, Visible Property, Width Property, ZOrder Property.

Methods

AddItem Method, BringToFront Method, Copy Method, CopyPicture Method, Cut Method, Delete Method, Duplicate Method, RemoveAllItems Method, RemoveItem Method, Select Method, SendToBack Method.