Column property (Microsoft Forms)
Specifies one or more items in a ListBox or ComboBox.
Syntax
object.Column(column, row) [= Variant ]
The Column property syntax has these parts:
Part | Description |
---|---|
object | Required. A valid object. |
column | Optional. An integer with a range from 0 to one less than the total number of columns. |
row | Optional. An integer with a range from 0 to one less than the total number of rows. |
Variant | Optional. Specifies a single value, a column of values, or a two-dimensional array to load into a ListBox or ComboBox. |
Settings
If you specify both the column and row values, Column reads or writes a specific item.
If you specify only the column value, the Column property reads or writes the specified column in the current row of the object. For example, MyListBox.Column (3) reads or writes the third column in MyListBox.
Column returns a Variant from the cursor. When a built-in cursor provides the value for Variant (such as when using the AddItem method), the value is a string. When an external cursor provides the value for Variant, formatting associated with the data is not included in the Variant.
Remarks
Use Column to assign the contents of a combo box or list box to another control, such as a text box. For example, you can set the ControlSource property of a text box to the value in the second column of a list box. If the user makes no selection when you refer to a column in a combo box or list box, the Column setting is Null. You can check for this condition by using the IsNull function.
You can also use Column to copy an entire two-dimensional array of values to a control. This syntax lets you quickly load a list of choices rather than individually loading each element of the list using AddItem.
Note
When copying data from a two-dimensional array, Column transposes the contents of the array in the control so that the contents of ListBox1.Column( X, Y ) is the same as MyArray( Y, X ). You can also use List to copy an array without transposing it.
See also
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.