Hi-
I have a listbox1 on on a userform named "month". When I click a commandbutton to activate a sheet, I want the contents of that sheet to be listed in listbox1 on userform "month". This works fine the first time, but when I click a button to select a diffrent sheet to activate, the list box doesnt change the contents from the first sheet to the next. Here is my code:
Private Sub CommandButton2_Click()
For Each s In Worksheets("sheet2").Range("a1:a100")
If s.Value = comboBox2.Value Then
x = s.Offset(0, 1).Value
Sheets(x).Activate
End If
Next s
Me.Hide
month.Show
Unload Me
The x represents the choice of which sheet to acivate, then shows a userform called "month". The listbox on the userform"month" shows the contents of the active sheet(x) the first time, but when I reselect another choice, the new sheet activates, but the old sheets contents still remain in listbox1. The row source is set at all times in the properties box to A2:I100.
I cant seem to figure out why its doing this?
I have a listbox1 on on a userform named "month". When I click a commandbutton to activate a sheet, I want the contents of that sheet to be listed in listbox1 on userform "month". This works fine the first time, but when I click a button to select a diffrent sheet to activate, the list box doesnt change the contents from the first sheet to the next. Here is my code:
Private Sub CommandButton2_Click()
For Each s In Worksheets("sheet2").Range("a1:a100")
If s.Value = comboBox2.Value Then
x = s.Offset(0, 1).Value
Sheets(x).Activate
End If
Next s
Me.Hide
month.Show
Unload Me
The x represents the choice of which sheet to acivate, then shows a userform called "month". The listbox on the userform"month" shows the contents of the active sheet(x) the first time, but when I reselect another choice, the new sheet activates, but the old sheets contents still remain in listbox1. The row source is set at all times in the properties box to A2:I100.
I cant seem to figure out why its doing this?