Hello
I'm trying to set up a combobox on a userform. I want the combobox to show one set of data but have a separate value associated with each selection, e.g. January =1, February = 2, etc.
"Aha!", I thought, "BoundColumn and TextColumn is exactly what I need." However, I can't get this to work! Despite setting BoundColumn and TextColumn, I always see _all_ the columns in the control. Even the Excel helpfile example shows all the columns. What am I doing wrong?
Another, related problem is that the online Excel help implies that the column wdiths can be set individually. But the columnwidths property of a combobox or listbox only seems to be able to be set for ALL columns.
I''m using Excel 97 under Windows NT.
Does anyone have any suggestions?
Regards
HedgePig
P.S. Am posting the helpfile example too.
From the Excel 97 online help.
==================================================
The following example uses the TextColumn property to identify the column of data in a ListBox that supplies data for its Text property. This example sets the third column of the ListBox as the text column. As you select an entry from the ListBox, the value from the TextColumn will be displayed in the Label.
This example also demonstrates how to load a multicolumn ListBox using the AddItem method and the List property.
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.
· A TextBox named TextBox1.
Private Sub UserForm_Initialize()
ListBox1.ColumnCount = 3
ListBox1.AddItem "Row 1, Col 1"
ListBox1.List(0, 1) = "Row 1, Col 2"
ListBox1.List(0, 2) = "Row 1, Col 3"
ListBox1.AddItem "Row 2, Col 1"
ListBox1.List(1, 1) = "Row 2, Col 2"
ListBox1.List(1, 2) = "Row 2, Col 3"
ListBox1.AddItem "Row 3, Col 1"
ListBox1.List(2, 1) = "Row 3, Col 2"
ListBox1.List(2, 2) = "Row 3, Col 3"
ListBox1.TextColumn = 3
End Sub
Private Sub ListBox1_Change()
TextBox1.Text = ListBox1.Text
End Sub
Copyright(c) 1996 Microsoft Corporation.
I'm trying to set up a combobox on a userform. I want the combobox to show one set of data but have a separate value associated with each selection, e.g. January =1, February = 2, etc.
"Aha!", I thought, "BoundColumn and TextColumn is exactly what I need." However, I can't get this to work! Despite setting BoundColumn and TextColumn, I always see _all_ the columns in the control. Even the Excel helpfile example shows all the columns. What am I doing wrong?
Another, related problem is that the online Excel help implies that the column wdiths can be set individually. But the columnwidths property of a combobox or listbox only seems to be able to be set for ALL columns.
I''m using Excel 97 under Windows NT.
Does anyone have any suggestions?
Regards
HedgePig
P.S. Am posting the helpfile example too.
From the Excel 97 online help.
==================================================
The following example uses the TextColumn property to identify the column of data in a ListBox that supplies data for its Text property. This example sets the third column of the ListBox as the text column. As you select an entry from the ListBox, the value from the TextColumn will be displayed in the Label.
This example also demonstrates how to load a multicolumn ListBox using the AddItem method and the List property.
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.
· A TextBox named TextBox1.
Private Sub UserForm_Initialize()
ListBox1.ColumnCount = 3
ListBox1.AddItem "Row 1, Col 1"
ListBox1.List(0, 1) = "Row 1, Col 2"
ListBox1.List(0, 2) = "Row 1, Col 3"
ListBox1.AddItem "Row 2, Col 1"
ListBox1.List(1, 1) = "Row 2, Col 2"
ListBox1.List(1, 2) = "Row 2, Col 3"
ListBox1.AddItem "Row 3, Col 1"
ListBox1.List(2, 1) = "Row 3, Col 2"
ListBox1.List(2, 2) = "Row 3, Col 3"
ListBox1.TextColumn = 3
End Sub
Private Sub ListBox1_Change()
TextBox1.Text = ListBox1.Text
End Sub
Copyright(c) 1996 Microsoft Corporation.