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:
[TABLE="width: 253"]
<tbody>[TR]
[TD="width: 123"]Manager
[/TD]
[TD="width: 130"]Employee
[/TD]
[/TR]
[TR]
[TD="width: 123"]A
[/TD]
[TD="align: right"]1
[/TD]
[/TR]
[TR]
[TD="width: 123"]A
[/TD]
[TD="align: right"]2
[/TD]
[/TR]
[TR]
[TD="width: 123"]A
[/TD]
[TD="align: right"]3
[/TD]
[/TR]
[TR]
[TD="width: 123"]A
[/TD]
[TD="align: right"]4
[/TD]
[/TR]
[TR]
[TD="width: 123"]B
[/TD]
[TD="align: right"]5
[/TD]
[/TR]
[TR]
[TD="width: 123"]B
[/TD]
[TD="align: right"]6
[/TD]
[/TR]
[TR]
[TD="width: 123"]B
[/TD]
[TD="align: right"]7
[/TD]
[/TR]
[TR]
[TD="width: 123"]B
[/TD]
[TD="align: right"]8
[/TD]
[/TR]
[TR]
[TD="width: 123"]C
[/TD]
[TD="align: right"]9
[/TD]
[/TR]
[TR]
[TD="width: 123"]C
[/TD]
[TD="align: right"]10
[/TD]
[/TR]
[TR]
[TD="width: 123"]C
[/TD]
[TD="align: right"]11
[/TD]
[/TR]
[TR]
[TD="width: 123"]C
[/TD]
[TD="align: right"]12
[/TD]
[/TR]
</tbody>[/TABLE]
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
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:
[TABLE="width: 253"]
<tbody>[TR]
[TD="width: 123"]Manager
[/TD]
[TD="width: 130"]Employee
[/TD]
[/TR]
[TR]
[TD="width: 123"]A
[/TD]
[TD="align: right"]1
[/TD]
[/TR]
[TR]
[TD="width: 123"]A
[/TD]
[TD="align: right"]2
[/TD]
[/TR]
[TR]
[TD="width: 123"]A
[/TD]
[TD="align: right"]3
[/TD]
[/TR]
[TR]
[TD="width: 123"]A
[/TD]
[TD="align: right"]4
[/TD]
[/TR]
[TR]
[TD="width: 123"]B
[/TD]
[TD="align: right"]5
[/TD]
[/TR]
[TR]
[TD="width: 123"]B
[/TD]
[TD="align: right"]6
[/TD]
[/TR]
[TR]
[TD="width: 123"]B
[/TD]
[TD="align: right"]7
[/TD]
[/TR]
[TR]
[TD="width: 123"]B
[/TD]
[TD="align: right"]8
[/TD]
[/TR]
[TR]
[TD="width: 123"]C
[/TD]
[TD="align: right"]9
[/TD]
[/TR]
[TR]
[TD="width: 123"]C
[/TD]
[TD="align: right"]10
[/TD]
[/TR]
[TR]
[TD="width: 123"]C
[/TD]
[TD="align: right"]11
[/TD]
[/TR]
[TR]
[TD="width: 123"]C
[/TD]
[TD="align: right"]12
[/TD]
[/TR]
</tbody>[/TABLE]
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