active combobox - possible to configure as display value andcoordinate value?

  • Thread starter Thread starter oldyork90
  • Start date Start date
O

oldyork90

I have a active combobox that lists colors

red
green
purple

When the user select the color and the _change event fires I want to see
a secondary value related to the color. For example, if red is selected I want
to read "fire", or if green is selected, I want to read "grass".

I want this information contained within the control. Is this possible? Like a drop down in HTML that has a name and value. You don't see the value, just the name.

thank you
 
I have a active combobox that lists colors
red
green
purple

When the user select the color and the _change event fires I want to
see a secondary value related to the color. For example, if red is
selected I want to read "fire", or if green is selected, I want to
read "grass".

I want this information contained within the control. Is this
possible? Like a drop down in HTML that has a name and value. You
don't see the value, just the name.

thank you

You need to use the ColumnCount property, set the color column as the
only one to display, set the value column as the BoundColumn. The value
in the BoundColumn will always be returned when an item is selected...

Put the following in the code module for the sheet containing
ComboBox1:

Option Explicit

Private Sub ComboBox1_Change()
With Me.ComboBox1
If .Text <> "" Then MsgBox .Value
End With
End Sub

Private Sub Worksheet_Activate()
Dim vList
vList = Me.Range("A2:B3")
With Me.ComboBox1
.ColumnCount = 2
.BoundColumn = 1
.ColumnWidths = "0,25" '//edit to suit
If .ListCount = 0 Then .List = vList
End With
End Sub

Insert the following in A2:B3 on the sheet containing ComboBox1...

fire red
water blue

Now cause the Sheet's _Activate event to fire so the combobox gets
setup & populated. Select a color and see what displays in the msgbox.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
Back
Top