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

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
 
G

GS

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top