ListBox control, BoundColumn, ControlSource, RowSource properties 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.
  • Make sure cell A6 contains no data.
Private Sub UserForm_Initialize() 
 
ListBox1.ColumnCount = 5 
ListBox1.RowSource = "a1:e4" 
 
ListBox1.ControlSource = "a6" 
'Place the ListIndex into cell a6 
ListBox1.BoundColumn = 0 
End Sub

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.