• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Let me point out my mistake in my code for list boxes

I have a user form having

1.Option buttons named "A,B,C,D,E,F,G"
2.Two list boxes named lstbox1 and lstbox2.

I have write a code in such away that when clicked on any option button,its related items appears on list box1 and so on.
And when clicked on any item in list box1,the items shows in the listbox2 dependent on listbox1.

Code:
Private Sub lstbox1_Click()
Select Case lstbox1.Text
Case "Allowances"
            lstbox2.RowSource = "Allowances"
        Case "Bonus"
            lstbox2.RowSource = "Bonus"
        Case "Computer & Accessories"
            lstbox2.RowSource = "Computer___Accessories"
        Case "Charity"
            lstbox2.RowSource = "Charity"
           
        Case "Drawings"
            lstbox2.RowSource = "Drawings"
           
        Case "Entertainment"
            lstbox2.RowSource = "Entertainment"
           
        Case "Fuel_Expenses"
            lstbox2.RowSource = "Fuel_Expenses"
           
        Case "Graduity"
            lstbox2.RowSource = "Graduity"
           
        Case "Holidays"
            lstbox2.RowSource = "Holidays"
        Case Else: lstbox2.RowSource = ""
       
        End Select
End Sub

Private Sub OptionButton15_Click()
lstbox1.RowSource = "A"
End Sub

Private Sub OptionButton16_Click()
lstbox1.RowSource = "B"
End Sub

Private Sub OptionButton17_Click()
lstbox1.RowSource = "CEE"
End Sub

Private Sub OptionButton18_Click()
lstbox1.RowSource = "D"
End Sub

Private Sub OptionButton19_Click()
lstbox1.RowSource = "H"
End Sub

Private Sub OptionButton24_Click()
lstbox1.RowSource = "E"
End Sub

Private Sub OptionButton25_Click()
lstbox1.RowSource = "F"
End Sub

Private Sub OptionButton28_Click()
lstbox1.RowSource = "G"
End Sub

My problem is that in the above code when i clicked on listbox1 to select an item ,the ltstbox2 shows nothing for some code line . I mean that some code are working and some are not.Please point out my mistake in my code.

I have upload my file to understand my problem better

Thanks
 

Attachments

  • COPYDD 123.xlsm
    114.4 KB · Views: 4
Back
Top