Combobox Add Item

M

MBlake

Hi,
An earlier post reply suggested that using AddItem for a ComboBox, I have
been looking at this and could do with a little more advice please.

I need a ComboBox to give a range of options that are dependant upon a
listbox. I then need a second combobox to take the 1st combobox selected
value and give further choices.

I have created the named ranges, these are - (1) UNIT, (2) categories and
(3) Options. So, categories is dependant upon Unit and Options are then
dependant upon categories.

Can someone advise the code to reference the listbox and then populate the
comboboxes please.

Any help or a url would be excellent,
Mickey
 
R

Ron de Bruin

Hi Mickey

You can use this

0 = the first item in the listbox

Private Sub ListBox1_Click()
If Me.ListBox1.ListIndex = 0 Then
Me.ComboBox1.List = Sheets("sheet1").Range("UNIT").Value
' other code
End If
End Sub
 
M

MBlake

Hi Ron,
Many thanks for your kind reply. I have been a little slow in responding as
I am struggling with this. Can you explain what the line 'other code'
refers to please.

Thanks,
Mickey
 
R

Ron de Bruin

Hi Mickey

In the example if you select the first item in the listbox it will fill
the first combo with this line
Me.ComboBox1.List = Sheets("sheet1").Range("UNIT").Value

Maybe you want to fill more comboboxes with a range that's why I add the
' other code
in the example

You can use another If...End If for the second item in the listbox
If Me.ListBox1.ListIndex = 1 Then
'your code
End If
 
M

MBlake

Cheers Ron,
I'll get back to the code now and see what I can work out. I really
appreciate your help and am enjoying Excel despite the headaches :)

Mickey
 

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