listbox not working?

Todd_M

Board Regular
Joined
Feb 24, 2002
Messages
117
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?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,213,543
Messages
6,114,243
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top