ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Combo Box Item (https://www.excelbanter.com/excel-programming/286566-combo-box-item.html)

alfaboost

Combo Box Item
 
How to add item in combo box with values from 2 different columns
Thank'

--
Message posted from http://www.ExcelForum.com


David Coleman

Combo Box Item
 
Hi there

Do you want a list of two sets of values?

Col 1, Item 1 Col2, Item 1
Col 1, Item 2 Col2, Item 2
Col 1, Item 3 Col2, Item 3
Col 1, Item 4 Col2, Item 4

Or a single list made up of the two columns?

Col1,Item1 & Col2, Item1
Col1,Item2 & Col2, Item2
Col1,Item3 & Col2, Item3
Col1,Item4 & Col2, Item4

Or a single column with entries from two columns?

Col1,Item1
Col1,Item2
Col1,Item3
Col1,Item4
Col2, Item1
Col2, Item2
Col2, Item3
Col2, Item4

Are the two columns next to each other (e.g. Col A & B)?

====

Basically you can either use

combobox1.additem range("a10").value to add one value at a time (or use
variables add a range)

or you can use the

combobox1.rowsource ("a1:b10") to add multiple values at once (this
actually links the items in the combobox to the cells on the sheet)

Hope this gives you some ideas - if you want more information, answer the
questions above and I'll look tomorrow once I'm over my hangover!

Best wishes

David



"alfaboost" wrote in message
...
How to add item in combo box with values from 2 different columns?
Thank's


---
Message posted from http://www.ExcelForum.com/




alfaboost[_2_]

Combo Box Item
 
Thank's for david, but i still got the problem.
I have data like this:

A B
1 10 11
2 12 13
3 14 15
4 16 17
5 18 19

I like those data shows in combobox item like this :

10
11
12
13
14
15
16
17
18
19

So, if i want those data shows as item in combobox from the control box
menu, what should i do? I' ve try this :

Private Sub ComboBox1_Change()
ComboBox1.AddItem Range("a1: b5")
End Sub

But why it still doesn't work? am i made mistake or there's something
that i don't know? please give me advise...Thank's


---
Message posted from http://www.ExcelForum.com/


alfaboost[_3_]

Combo Box Item
 
Thank's for david, but i still got the problem.
I have data like this:

Col A Col B
1 10 11
2 12 13
3 14 15
4 16 17
5 18 19

I like those data shows in combobox item like this :

10
11
12
13
14
15
16
17
18
19

So, if i want those data shows as item in combobox from the control box
menu, what should i do? I' ve try this :

Private Sub ComboBox1_Change()
ComboBox1.AddItem Range("a1: b5")
End Sub

But why it still doesn't work? am i made mistake or there's something
that i don't know? please give me advise...Thank's


---
Message posted from http://www.ExcelForum.com/


Rob van Gelder[_4_]

Combo Box Item
 
Private Sub UserForm_Initialize()
Dim i As Integer

For i = 1 To 5
ComboBox1.AddItem Cells(i, 1).Value
ComboBox1.AddItem Cells(i, 2).Value
Next
End Sub


Rob


"alfaboost " wrote in message
...
Thank's for david, but i still got the problem.
I have data like this:

Col A Col B
1 10 11
2 12 13
3 14 15
4 16 17
5 18 19

I like those data shows in combobox item like this :

10
11
12
13
14
15
16
17
18
19

So, if i want those data shows as item in combobox from the control box
menu, what should i do? I' ve try this :

Private Sub ComboBox1_Change()
ComboBox1.AddItem Range("a1: b5")
End Sub

But why it still doesn't work? am i made mistake or there's something
that i don't know? please give me advise...Thank's


---
Message posted from http://www.ExcelForum.com/




Robbyn[_2_]

Combo Box Item
 
David,

If I may ask a question here..

How would I populate a list box data using a single list of information from 2 columns? 'Col1,Item1 & Col2, Item1'

Can it be done?

David Coleman

Combo Box Item
 
Hi Robbyn

Sub twolist()
Dim x As Integer

x = 1

UserForm1.ListBox1.Clear

While (Range("a" & x).Value < "")
UserForm1.ListBox1.AddItem Range("A" & x).Value & Range("b" &
x).Value
x = x + 1
Wend
UserForm1.Show

End Sub

will do exactly that - however, you lost the useful ability to set rowsource
(ie link back to the actual sheet).

Alternatively, insert an additional column which just concatenates the two
cells that you're interested in and set the rowsource to the new combined
column.

Regards

David




"Robbyn" wrote in message
...
David,

If I may ask a question here..

How would I populate a list box data using a single list of information

from 2 columns? 'Col1,Item1 & Col2, Item1'

Can it be done?




Robbyn[_2_]

Combo Box Item
 
Okay, good idea. Thanks much

Robbyn


All times are GMT +1. The time now is 11:58 PM.

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