On a UserForm I have two listboxes. the values in the second list box changes depending what is selected in the first listbox.
My problem is that the controlsource of the first list box (which the second list box depends on) seems to disappear immediately after the user has selected a value from it.
Even worse, when i return to the worksheet and attempt to enter a value that was in the rowsource of the first list box, that disappears as well. Any other value stays, just not those in its rowsource.
This is extremely annoying, and i've got no idea what the problem is.
My code for the second list box is:
Private Sub ListBox2_AfterUpdate()
If Range("MonthChoice") = "January" Then
ComboBox2.RowSource = "Jan"
ElseIf Range("MonthChoice") = "February" Then
ComboBox2.RowSource = "Feb"
ElseIf Range("MonthChoice") = "March" Then
ComboBox2.RowSource = "Mar"
ElseIf Range("MonthChoice") = "April" Then
ComboBox2.RowSource = "April"
ElseIf Range("MonthChoice") = "May" Then
ComboBox2.RowSource = "May"
ElseIf Range("MonthChoice") = "June" Then
ComboBox2.RowSource = "Jun"
ElseIf Range("MonthChoice") = "July" Then
ComboBox2.RowSource = "Jul"
ElseIf Range("MonthChoice") = "August" Then
ComboBox2.RowSource = "Aug"
ElseIf Range("MonthChoice") = "September" Then
ComboBox2.RowSource = "Sep"
ElseIf Range("MonthChoice") = "October" Then
ComboBox2.RowSource = "Oct"
ElseIf Range("MonthChoice") = "November" Then
ComboBox2.RowSource = "Nov"
ElseIf Range("MonthChoice") = "December" Then
ComboBox2.RowSource = "Dec"
End If
End Sub
My problem is that the controlsource of the first list box (which the second list box depends on) seems to disappear immediately after the user has selected a value from it.
Even worse, when i return to the worksheet and attempt to enter a value that was in the rowsource of the first list box, that disappears as well. Any other value stays, just not those in its rowsource.
This is extremely annoying, and i've got no idea what the problem is.
My code for the second list box is:
Private Sub ListBox2_AfterUpdate()
If Range("MonthChoice") = "January" Then
ComboBox2.RowSource = "Jan"
ElseIf Range("MonthChoice") = "February" Then
ComboBox2.RowSource = "Feb"
ElseIf Range("MonthChoice") = "March" Then
ComboBox2.RowSource = "Mar"
ElseIf Range("MonthChoice") = "April" Then
ComboBox2.RowSource = "April"
ElseIf Range("MonthChoice") = "May" Then
ComboBox2.RowSource = "May"
ElseIf Range("MonthChoice") = "June" Then
ComboBox2.RowSource = "Jun"
ElseIf Range("MonthChoice") = "July" Then
ComboBox2.RowSource = "Jul"
ElseIf Range("MonthChoice") = "August" Then
ComboBox2.RowSource = "Aug"
ElseIf Range("MonthChoice") = "September" Then
ComboBox2.RowSource = "Sep"
ElseIf Range("MonthChoice") = "October" Then
ComboBox2.RowSource = "Oct"
ElseIf Range("MonthChoice") = "November" Then
ComboBox2.RowSource = "Nov"
ElseIf Range("MonthChoice") = "December" Then
ComboBox2.RowSource = "Dec"
End If
End Sub