I haved a spreadsheet that will be used for performing various calculations for different tests. Each test is on a separate sheet, with sheet 1 being used to select which test the user wants to perform. Since additional tests are being added as they get qualified, I wanted to automate the listbox so when the workbook was opened each sheet name would be added to column a, a sort would be performed on that column, and then the ListFillRange would be updated for the list box. However, it appears that the list box gets populated prior to the sort completing, and only after clicking on each entry in the list box does everything look right. This will obviously not be acceptable for the end user. How do I make sure the list does not get refreshed until after the sort is complete? Below is the code I used to do this.
Note, this does not always create the problem, but enough times to aggravate me. Any help would be appreciated.
Code:
Private Sub Workbook_Activate()
Dim i As Integer
i = 1
For Each ws In Worksheets
If ws.Name Like "OST*" Then
Worksheets("TestSelect").Range("A" & i).Value = ws.Name
i = i + 1
End If
Next ws
i = i - 1
Worksheets("TestSelect").Range("A1").Sort Key1:=Worksheets("TestSelect").Columns("A")
Worksheets("TestSelect").SelectedTest.ListFillRange = "a1:a" & i
End Sub
Note, this does not always create the problem, but enough times to aggravate me. Any help would be appreciated.