4 dependent combo boxes using VBA

Chelly Roho

New Member
Joined
Feb 8, 2018
Messages
6
I've been working on this for a while. I can relate two combo boxes only. Example of my data:

Region District Facilities
Tangwa Tangwa_Disctict Tangwa_District_Facilities

The problem I believe is that Region on has 4 entries, District has 8 but there are over 400 facilities each tied to a District which is tied to a Region. I used the Select Case routine for the first two boxes but trying to do this with the 3rd box yields an empty box after a ton of typing. Please help.

Chelly Roho
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi, good morning.

Do you using a userform?

Yes I'm using userform combo boxes. I have many columns and each with a unique name. My cmbox1 is titled REGIONS and it has 5 regions, cmbox2 is titled DISTRICTS and it has 9 districts. I have a cmbox4 for months that I filled in using Rowsource, this box is independent. The problem I'm having is that the 9 districts each have at least 10 facilities. I've been trying the select case but it's not working for the cmbox3.
 
Upvote 0
Good Morning,

My mind is already at the end of the project and I can't get past the first stage. I'm wondering if .additem would work or even an "if, then" statement. I don't know.
 
Upvote 0
Keep calm please ok?

I need to think like this: Each district and facility registry must have a relationship with the region.

Example:

[TABLE="width: 192"]
<colgroup><col span="2"></colgroup><tbody>[TR]
[TD]IdRegion[/TD]
[TD]NameRegion[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]re1[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]re2[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]re3[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]re4[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]re5[/TD]
[/TR]
</tbody>[/TABLE]


[TABLE="width: 306"]
<colgroup><col span="3"></colgroup><tbody>[TR]
[TD]IdDistrict[/TD]
[TD]NameDistrict[/TD]
[TD]RegionDistrict[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]di1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]di2[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]di3[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]di4[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]di5[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]di6[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]di7[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]di8[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]di9[/TD]
[TD]4[/TD]
[/TR]
</tbody>[/TABLE]



[TABLE="width: 424"]
<colgroup><col span="4"></colgroup><tbody>[TR]
[TD]IdFacility[/TD]
[TD]NameFacility[/TD]
[TD]RegionFacility[/TD]
[TD]DistrictFAcility[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Facility1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Facility2[/TD]
[TD]2[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Facility3[/TD]
[TD]3[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Facility4[/TD]
[TD]4[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Facility5[/TD]
[TD]5[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]Facility6[/TD]
[TD]1[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]Facility7[/TD]
[TD]2[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]Facility8[/TD]
[TD]3[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]Facility9[/TD]
[TD]4[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]Facility10[/TD]
[TD]5[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]Facility11[/TD]
[TD]1[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]Facility12[/TD]
[TD]2[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]13[/TD]
[TD]Facility13[/TD]
[TD]3[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]14[/TD]
[TD]Facility14[/TD]
[TD]4[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]15[/TD]
[TD]Facility15[/TD]
[TD]5[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]16[/TD]
[TD]Facility16[/TD]
[TD]1[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]17[/TD]
[TD]Facility17[/TD]
[TD]2[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]18[/TD]
[TD]Facility18[/TD]
[TD]3[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]19[/TD]
[TD]Facility19[/TD]
[TD]4[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]20[/TD]
[TD]Facility20[/TD]
[TD]5[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]21[/TD]
[TD]Facility21[/TD]
[TD]1[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]22[/TD]
[TD]Facility22[/TD]
[TD]2[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]23[/TD]
[TD]Facility23[/TD]
[TD]3[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]24[/TD]
[TD]Facility24[/TD]
[TD]4[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]25[/TD]
[TD]Facility25[/TD]
[TD]5[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]26[/TD]
[TD]Facility26[/TD]
[TD]1[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]27[/TD]
[TD]Facility27[/TD]
[TD]2[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]28[/TD]
[TD]Facility28[/TD]
[TD]3[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]29[/TD]
[TD]Facility29[/TD]
[TD]4[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]30[/TD]
[TD]Facility30[/TD]
[TD]5[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]31[/TD]
[TD]Facility31[/TD]
[TD]1[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]32[/TD]
[TD]Facility32[/TD]
[TD]2[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]33[/TD]
[TD]Facility33[/TD]
[TD]3[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]34[/TD]
[TD]Facility34[/TD]
[TD]4[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]35[/TD]
[TD]Facility35[/TD]
[TD]5[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]36[/TD]
[TD]Facility36[/TD]
[TD]1[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]37[/TD]
[TD]Facility37[/TD]
[TD]2[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]38[/TD]
[TD]Facility38[/TD]
[TD]3[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]39[/TD]
[TD]Facility39[/TD]
[TD]4[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]40[/TD]
[TD]Facility40[/TD]
[TD]5[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]41[/TD]
[TD]Facility41[/TD]
[TD]1[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]42[/TD]
[TD]Facility42[/TD]
[TD]2[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]43[/TD]
[TD]Facility43[/TD]
[TD]3[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]44[/TD]
[TD]Facility44[/TD]
[TD]4[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]45[/TD]
[TD]Facility45[/TD]
[TD]5[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]46[/TD]
[TD]Facility46[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]47[/TD]
[TD]Facility47[/TD]
[TD]2[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]48[/TD]
[TD]Facility48[/TD]
[TD]3[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]49[/TD]
[TD]Facility49[/TD]
[TD]4[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]50[/TD]
[TD]Facility50[/TD]
[TD]5[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]51[/TD]
[TD]Facility51[/TD]
[TD]1[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]52[/TD]
[TD]Facility52[/TD]
[TD]2[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]53[/TD]
[TD]Facility53[/TD]
[TD]3[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]54[/TD]
[TD]Facility54[/TD]
[TD]4[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]55[/TD]
[TD]Facility55[/TD]
[TD]5[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]56[/TD]
[TD]Facility56[/TD]
[TD]1[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]57[/TD]
[TD]Facility57[/TD]
[TD]2[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]58[/TD]
[TD]Facility58[/TD]
[TD]3[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]59[/TD]
[TD]Facility59[/TD]
[TD]4[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]60[/TD]
[TD]Facility60[/TD]
[TD]5[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]61[/TD]
[TD]Facility61[/TD]
[TD]1[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]62[/TD]
[TD]Facility62[/TD]
[TD]2[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]63[/TD]
[TD]Facility63[/TD]
[TD]3[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]64[/TD]
[TD]Facility64[/TD]
[TD]4[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]65[/TD]
[TD]Facility65[/TD]
[TD]5[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]66[/TD]
[TD]Facility66[/TD]
[TD]1[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]67[/TD]
[TD]Facility67[/TD]
[TD]2[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]68[/TD]
[TD]Facility68[/TD]
[TD]3[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]69[/TD]
[TD]Facility69[/TD]
[TD]4[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]70[/TD]
[TD]Facility70[/TD]
[TD]5[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]71[/TD]
[TD]Facility71[/TD]
[TD]1[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]72[/TD]
[TD]Facility72[/TD]
[TD]2[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]73[/TD]
[TD]Facility73[/TD]
[TD]3[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]74[/TD]
[TD]Facility74[/TD]
[TD]4[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]75[/TD]
[TD]Facility75[/TD]
[TD]5[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]76[/TD]
[TD]Facility76[/TD]
[TD]1[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]77[/TD]
[TD]Facility77[/TD]
[TD]2[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]78[/TD]
[TD]Facility78[/TD]
[TD]3[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]79[/TD]
[TD]Facility79[/TD]
[TD]4[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]80[/TD]
[TD]Facility80[/TD]
[TD]5[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]81[/TD]
[TD]Facility81[/TD]
[TD]1[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]82[/TD]
[TD]Facility82[/TD]
[TD]2[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]83[/TD]
[TD]Facility83[/TD]
[TD]3[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]84[/TD]
[TD]Facility84[/TD]
[TD]4[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]85[/TD]
[TD]Facility85[/TD]
[TD]5[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]86[/TD]
[TD]Facility86[/TD]
[TD]1[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]87[/TD]
[TD]Facility87[/TD]
[TD]2[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]88[/TD]
[TD]Facility88[/TD]
[TD]3[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]89[/TD]
[TD]Facility89[/TD]
[TD]4[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]90[/TD]
[TD]Facility90[/TD]
[TD]5[/TD]
[TD]9[/TD]
[/TR]
</tbody>[/TABLE]

That way you will be able to make the relationship between the combos work as you need it.
I'm not done yet, I'll try to help you more, for now think about it ok?


Keep calm please.
 
Upvote 0
Thank you.

Region
a
b
c
d
e

Disctrict
Region a
1
2
3
4
Region b
1
2
3
4
5
6
District c
1
2
3
4

Then each District has several facilities attached.
District d
1
2
3
4
 
Upvote 0
So how do I do this. I've tried dynamic name range loop then case select. Two boxes work fine but the third is erroneous.

Chelly
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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