RowSource Property
Applies To
ComboBox control, ListBox control.
Description
Specifies the source providing a list for a ComboBox or ListBox.
Syntax
object.RowSource [= String]
The RowSource property syntax has these parts:
Part | Description |
|
object | Required. A valid object. |
String | Optional. The source of the list for the ComboBox or ListBox. |
Remarks
The RowSource property accepts worksheet ranges from Microsoft Excel.
Example
The following example uses a range of worksheet cells in a ListBox and, when the user selects a row from the list, displays the row index in another worksheet cell. This code sample uses the RowSource, BoundColumn, and ControlSource properties.
To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains a ListBox named ListBox1. In the worksheet, enter data in cells A1:E4. You also need to make sure cell A6 contains no data.
Private Sub UserForm_Initialize()
ListBox1.ColumnCount = 5
ListBox1.RowSource = "a1:e4"
ListBox1.ControlSource = "a6"
ListBox1.BoundColumn = 0 'Place the ListIndex into cell a6
End Sub