Combobox Add Item

  • Thread starter Thread starter MBlake
  • Start date Start date
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
 
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
 
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
 
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
 
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
 
Back
Top