View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy Patrick Molloy is offline
external usenet poster
 
Posts: 1,049
Default Dependant combo box in Excel form

do you want to send me your workbook?


"Amy Brooks" wrote in message
...
This doesn't seem to be working for me, maybe because I'm using a user
form??
I viewed the form code and added the code there, but when I select a
department, the following message appears:
__________________________________________________ __________________
Compile error:

Method or data member not found
__________________________________________________ __________________

.ListFillRange = "emp." & cboDepartment

and highlights the cboDepartment in the above string.

:( Any ideas why it's doing this? Oh, and it won't let me add the Option
Explicit to the beginning, otherwise it goes to the end of the previous
Sub.
I don't know if this would affect it's functionality.



"Patrick Molloy" wrote:

I have a demo book for indirect validation
http://www.xl-expert.com/IndirectValidation.htm
this is using validation in cells

Are you using a userform?
if you are, then the code should go in the department listbox change
event
If you've dropped these onto a sheet, then you'll code the objects on the
sheet's code page (right click the sheet tab & select View Code)

If you have the combos on a sheet...
range name "Department" - table of departments
range name "emp.Sales" - table of employees in sales
range name "emp.Marketing"
range name "emp.Accounts"

combobox cboDepartments : ListFillRange: Departments
sheet code page:
Option Explicit
Private Sub cboDepartment_Change()
With cboEmployee
.ListFillRange = "emp." & cboDepartment
.Text = "<choose"
End With
End Sub


please see the Filtered Combobox on the weblink - its this example


"Amy Brooks" wrote in message
...
Hi,

I've tried to modify the following code (originally intended for an
Outlook
form) to work in an Excel form. As I expected, it doesn't work, but I'm
not
entirely sure why. My guess is that either, I've put it in the wrong
place,
the sub name is wrong, or the code itself has a problem. The code is
supposed
to make one combo box (Employee) dependant on another (Department). For
example, if I selected the Marketing department from the Department
combo
box, I would only get the options A Brock, A Brooks, and V Woodford.

What should I use as the Sub name?
Where is the code supposed to go?
Are there any other mistakes in the code that could be causing it not
to
work?

__________________________________________________ __________________
Sub cboEmployee_List()
Select Case Item.UserProperties("cboDepartment")
Case "Accounts"
cboEmployee.List = Split("C Dawson,,J Cooper,L
Bottomley",
",")
Case "Sales"
cboEmployee.List = Split("A Soar,B Miller,D Padgett,P
North",
",")
Case "Marketing"
cboEmployee.List = Split("A Brock,V Woodford,A Brooks",
",")
End Select
End Sub
__________________________________________________ __________________

Thanks!
Amy