ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Combobox Add Item (https://www.excelbanter.com/excel-programming/328408-combobox-add-item.html)

MBlake

Combobox Add Item
 
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



Ron de Bruin

Combobox Add Item
 
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


--
Regards Ron de Bruin
http://www.rondebruin.nl



"MBlake" wrote in message ...
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




MBlake

Combobox Add Item
 
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


"Ron de Bruin" wrote in message
...
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


--
Regards Ron de Bruin
http://www.rondebruin.nl



"MBlake" wrote in message
...
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






Ron de Bruin

Combobox Add Item
 
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


--
Regards Ron de Bruin
http://www.rondebruin.nl



"MBlake" wrote in message ...
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


"Ron de Bruin" wrote in message ...
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


--
Regards Ron de Bruin
http://www.rondebruin.nl



"MBlake" wrote in message ...
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








MBlake

Combobox Add Item
 
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




All times are GMT +1. The time now is 09:05 PM.

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