Selected Property

This page is specific to the Visual Basic for Applications (VBA) Language Reference for Office 2010.

Returns or sets the selection state of items in a ListBox.


object.Selected( index ) [= Boolean]

The Selected property syntax has these parts:




Required. A valid object.


Required. An integer with a range from 0 to one less than the number of items in the list.


Optional. Whether an item is selected.


The settings for Boolean are:




The item is selected.


The item is not selected.


The Selected property is useful when users can make multiple selections. You can use this property to determine the selected rows in a multi-select list box. You can also use this property to select or deselect rows in a list from code.

The default value of this property is based on the current selection state of the ListBox.

For single-selection list boxes, the Value or ListIndex properties are recommended for getting and setting the selection. In this case, ListIndex returns the index of the selected item. However, in a multiple selection, ListIndex returns the index of the row contained within the focus rectangle, regardless of whether the row is actually selected.

When a list box control's MultiSelect property is set to None, only one row can have its Selected property set to True.

Entering a value that is out of range for the index does not generate an error message, but does not set a property for any item in the list.