ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Two values in a combobox (https://www.excelbanter.com/excel-programming/354080-two-values-combobox.html)

alvin Kuiper

Two values in a combobox
 
Hi
If i use
For Each b In rng3
combo_timer.AddItem b.Text
next

is there away to say the values are somthing and the tex are something else
like in a combobox in a database where what you see in the combobox are
text and the value are numbers.

In my case here i only give combo_timer a value B in rng3 but is there a way
to give another value also like text is somthing and the valuea are somthing?

regards

alvin



Jim Cone

Two values in a combobox
 
alvin,

Use two columns in the combo box.
Set the width of the second column to zero.
Set the second column as the bound column.
Put the data you want to display in the first column.
Put the data you want to use in the second column.

After doing the above then this worked for me...

Private Sub ComboBox1_Change()
'Adds the data from column two to the cell.
Range("A2").Value = ComboBox1.Value
End Sub

'Loads both columns with data from the range.
Private Sub UserForm_Initialize()
Dim varValues As Variant
varValues = Range("C5:D15").Value
ComboBox1.List = varValues
'-----------------------------------------
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"alvin Kuiper"
wrote in message...
Hi
If i use
For Each b In rng3
combo_timer.AddItem b.Text
next
is there away to say the values are somthing and the tex are something else
like in a combobox in a database where what you see in the combobox are
text and the value are numbers.
In my case here i only give combo_timer a value B in rng3 but is there a way
to give another value also like text is somthing and the valuea are somthing?
regards
alvin



alvin Kuiper

Two values in a combobox
 
Thanks

Alvin

"Jim Cone" wrote:

alvin,

Use two columns in the combo box.
Set the width of the second column to zero.
Set the second column as the bound column.
Put the data you want to display in the first column.
Put the data you want to use in the second column.

After doing the above then this worked for me...

Private Sub ComboBox1_Change()
'Adds the data from column two to the cell.
Range("A2").Value = ComboBox1.Value
End Sub

'Loads both columns with data from the range.
Private Sub UserForm_Initialize()
Dim varValues As Variant
varValues = Range("C5:D15").Value
ComboBox1.List = varValues
'-----------------------------------------
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"alvin Kuiper"
wrote in message...
Hi
If i use
For Each b In rng3
combo_timer.AddItem b.Text
next
is there away to say the values are somthing and the tex are something else
like in a combobox in a database where what you see in the combobox are
text and the value are numbers.
In my case here i only give combo_timer a value B in rng3 but is there a way
to give another value also like text is somthing and the valuea are somthing?
regards
alvin





All times are GMT +1. The time now is 10:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com