Combo Box Item

  • Thread starter Thread starter alfaboost
  • Start date Start date
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
 
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
 
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
 
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
 
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 said:
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'
 
Back
Top