View Single Post
 
Old 04-20-2013, 11:19 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

I agree with Paul, but bored I thought I would provide some sample code. First you don't say what type of form or what type of control. This assumes a UserForm with two listbox controls. You basically have to populate the first with the divisions and then populate the second with branches using the change event of the first:

Code:
Private Sub lstDiv_Change()
If lstDiv.ListIndex <> -1 Then
  With lstBranch
    .Enabled = True
    .Clear
    Select Case lstDiv.Value
      Case "Operations"
        .AddItem "QM"
        .AddItem "ET"
      Case "Engineering"
        .AddItem "A"
        .AddItem "M"
        .AddItem "E"
      Case "Medical"
        .AddItem "X"
        .AddItem "Y"
        .AddItem "Z"
      Case "Dental"
        .AddItem "X"
        .AddItem "Y"
        .AddItem "Z"
      Case "Weapons"
        .AddItem "TM"
        .AddItem "FTB"
        .AddItem "MT"
    End Select
  End With
Else
  With lstBranch
    .Clear
    .Enabled = False
    .Clear
  End With
End If
  
End Sub
Private Sub UserForm_Initialize()
With Me
  With .lstDiv
    .AddItem "Operations"
    .AddItem "Engineering"
    .AddItem "Medical"
    .AddItem "Dental"
    .AddItem "Weapons"
  End With
  .lstBranch.Enabled = False
End With
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote