Selected Property

Applies To

DrawingObjects Collection, ListBox Object, ListBoxes Collection.

Description

Returns or sets an array of Boolean values indicating the selection state of items in the list box. Each entry in the array corresponds to an entry in the list box, and is True if the entry is selected or False if it is not selected. Use this property to obtain the selected items in a multi-select list box. Read-write.

Remarks

For single-selection list boxes, it is easier to use the Value or ListIndex properties to get and set the selection.

See Also

ListIndex Property, Selection Property, Value Property.

Example

This example selects every other item in list box one on Sheet1.


Dim items() As Boolean
Set lbox = Worksheets("Sheet1").ListBoxes(1)
ReDim items(1 To lbox.ListCount)
For i = 1 To lbox.ListCount
    If i Mod 2 = 1 Then
        items(i) = True
    Else
        items(i) = False
    End If
Next
lbox.MultiSelect = xlExtended
lbox.Selected = items