Combo box to combo box with named ranges

Simmerin

New Member
Joined
Jun 24, 2011
Messages
20
Hi all,

I'm trying to setup a form where you select from one combo box a named range, then the second combo box fills with the values of the named range

i.e. you have a customer drop down with macrohard, orange, and lionux
and you select macrohard

then the contact list combo box is the contents of the named range macrohard and you can select people that work there i.e. William Fences but not people that work at the other companies i.e. Stephen Occupations
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
also, i dont want to do this with data validation, im trying to get this all on a pop up on startup form, i have the rest of the form working including the combobox where you select the named range. the last piece to this puzzle is the contact combo box
 
Upvote 0
If the values in the first listbox are the named ranges just use the selected value to populate the 2nd listbox.
Code:
Combobox2.List= Range(Combobox1.Value).Value
 
Upvote 0
I've tried this code with the necessary name changes, in both the change and initialize locations and i get nuffin......
 
Upvote 0
Where exactly did you put the code?

It should go in the change event of the first combobox.

If the names when wrong you would have got an error.
 
Upvote 0
oh i placed it in the change of the second, i shall fix and see

Edit: ok so now it works perfectly!.....if there is only one cell in the named range, i.e. it works with the customers that only have one contact. but the multiple contacts bring back a runtime error
 
Last edited:
Upvote 0
What exact code did you try?

Also what ranges do they named ranges cover?
 
Upvote 0
Code:
Private Sub cmbCustomer_Change()
cmbContact.Value = Range(cmbCustomer.Value).Value
End Sub

The named ranges select the contact names only
so for example, range name crabshack selects joe crab, and snow crab

also, the first drop down is

Code:
Me.cmbCustomer.List = Range("rangenamenozero").Value
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top