edwards1979
New Member
- Joined
- Oct 1, 2008
- Messages
- 24
I am using the following code to link 2 listboxes - the case outcome here could eventually become any one of 50 cases, therefore I was looking for a way of tidying up the code :-
Private Sub ListBox1_Click()
'Get the currently selected item
Select Case ListBox1.Value
'If Project Documents, set RowSource property of ListBox2
'to Column B.
Case "Project Documents"
ListBox2.RowSource = "Datasheet!H4:H18"
Case "MSE Procedures"
ListBox2.RowSource = "Datasheet!H19:H52"
Case "Administration"
ListBox2.RowSource = "Datasheet!H53:H60"
Case "Trackers"
ListBox2.RowSource = "Datasheet!H61:H64"
Case "Internet / Doc. Search"
ListBox2.RowSource = "Datasheet!H61:H64"
End Select
End Sub
(I have entered the row source of listbox1 into properties to give these case headings!)
Private Sub ListBox1_Click()
'Get the currently selected item
Select Case ListBox1.Value
'If Project Documents, set RowSource property of ListBox2
'to Column B.
Case "Project Documents"
ListBox2.RowSource = "Datasheet!H4:H18"
Case "MSE Procedures"
ListBox2.RowSource = "Datasheet!H19:H52"
Case "Administration"
ListBox2.RowSource = "Datasheet!H53:H60"
Case "Trackers"
ListBox2.RowSource = "Datasheet!H61:H64"
Case "Internet / Doc. Search"
ListBox2.RowSource = "Datasheet!H61:H64"
End Select
End Sub
(I have entered the row source of listbox1 into properties to give these case headings!)