Cascading (Dependent) Combo boxes in Excel Form using vba - Need Help

bgblanco

New Member
Joined
Jan 13, 2014
Messages
2
Hi, first I want to thank you in advance for helping me out.
I have developed a user form in excel. I have 2 combo boxes. The first one is Manager and the second one is Employee. Upon form initialize I populate all Managers and Employees from excel tabs with the code below (this populates everyone).
What I need help with, is I want to update the Employee combo box depending on what Manager is selected. So if Manager A is selected I only want to show the employees attached to Manager A, and If Manager B is selected I only want to show their employees, etc.
The table that I'm pulling from is on the 'EmployeeRefTable' tab and the information looks like this:
ManagerEmployee
A1
A2
A3
A4
B5
B6
B7
B8
C9
C10
C11
C12

<colgroup><col width="123" style="width: 92pt;"><col width="130" style="width: 98pt;"></colgroup><tbody>
</tbody>
Set DataSheet = ThisWorkbook.Worksheets("ManagerRefTable")
Set MyList = DataSheet.Range("A2:A50")
Rw = 1
cboManager.Clear
While MyList.Cells(Rw, 1).Value <> ""
cboManager.AddItem
cboManager.List(Rw - 1, 0) = MyList.Cells(Rw, 1).Value
cboManager.List(Rw - 1, 1) = MyList.Cells(Rw, 2).Value
Rw = Rw + 1
Wend

Set DataSheet = ThisWorkbook.Worksheets("EmployeeRefTable")
Set MyList = DataSheet.Range("B2:B250")
Rw = 1
cboEmployee.Clear
While MyList.Cells(Rw, 1).Value <> ""
cboEmployee.AddItem
cboEmployee.List(Rw - 1, 0) = MyList.Cells(Rw, 1).Value
cboEmployee.List(Rw - 1, 1) = MyList.Cells(Rw, 2).Value
Rw = Rw + 1
Wend
Thank you again,
Brian
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,215,204
Messages
6,123,630
Members
449,109
Latest member
Sebas8956

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