ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   combobox multiple columns (https://www.excelbanter.com/excel-programming/398083-combobox-multiple-columns.html)

Graham Y

combobox multiple columns
 
I use the following code to populate a combobox (on a userform) with a list
of names and associated numbers (colour codes)
Dim BuMs()
ReDim BuMs(y, 1)
BuMs(1,0)="Fred"
BuMs(1,1)=1
cmbBuMs.List = BuMs
The combobox displays the names, but when I process the form, I also want to
use the colur code, how do I access it?

Bob Phillips

combobox multiple columns
 
I think you will be unlucky with that one.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Graham Y" wrote in message
...
I use the following code to populate a combobox (on a userform) with a list
of names and associated numbers (colour codes)
Dim BuMs()
ReDim BuMs(y, 1)
BuMs(1,0)="Fred"
BuMs(1,1)=1
cmbBuMs.List = BuMs
The combobox displays the names, but when I process the form, I also want
to
use the colur code, how do I access it?




Graham Y

combobox multiple columns
 
Thanks Bob
Was hoping I might have missed something.
I'll just have to use the index to look the value up from the array.

"Bob Phillips" wrote:

I think you will be unlucky with that one.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Graham Y" wrote in message
...
I use the following code to populate a combobox (on a userform) with a list
of names and associated numbers (colour codes)
Dim BuMs()
ReDim BuMs(y, 1)
BuMs(1,0)="Fred"
BuMs(1,1)=1
cmbBuMs.List = BuMs
The combobox displays the names, but when I process the form, I also want
to
use the colur code, how do I access it?





Andy Pope

combobox multiple columns
 
Hi,

Can you not make use of the boundcolumn?

Private Sub UserForm_Initialize()

Dim BuMs(), y

y = 3

ReDim BuMs(y, 1)
BuMs(1, 0) = "Fred"
BuMs(1, 1) = 1
BuMs(2, 0) = "John"
BuMs(2, 1) = 3
BuMs(3, 0) = "Mike"
BuMs(3, 1) = 5

cmbBuMs.List = BuMs
cmbBuMs.BoundColumn = 2

End Sub
Private Sub cmbBuMs_Change()

MsgBox cmbBuMs.Text & vbLf & cmbBuMs.Value

End Sub

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"Graham Y" wrote in message
...
Thanks Bob
Was hoping I might have missed something.
I'll just have to use the index to look the value up from the array.

"Bob Phillips" wrote:

I think you will be unlucky with that one.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Graham Y" wrote in message
...
I use the following code to populate a combobox (on a userform) with a
list
of names and associated numbers (colour codes)
Dim BuMs()
ReDim BuMs(y, 1)
BuMs(1,0)="Fred"
BuMs(1,1)=1
cmbBuMs.List = BuMs
The combobox displays the names, but when I process the form, I also
want
to
use the colur code, how do I access it?







All times are GMT +1. The time now is 02:07 PM.

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