Name
control
.BoundColumn [= setting
]
Synopsis
Sets or returns the index of the column that determines the Value
property of the control. The following code loads three columns of data from the DataForm worksheet into a combo box and displays the value of the third column when the user selects an item from the list:
Private Sub UserForm_Initialize( ) Dim rng As Range ComboBox1.ColumnCount = 3 Set rng = Worksheets("DataForm").UsedRange ComboBox1.RowSource = rng.Address ComboBox1.BoundColumn = 3 End Sub Private Sub ComboBox1_Change( ) If ComboBox1.Value <> "" Then _ MsgBox "Selected value is: " & ComboBox1.Value End Sub
Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.