I want to execute two macros every time a listbox change event takes place...it will be the same two macros every time a different item is selected in the listbox. Based on what is selected in the multicolumn listbox, one macro copies data from the listbox range and passes it to multiple text box values. The other macro runs a Solver with this data. For some reason, the code only works when I select an item in the listbox for the first time. When I change the selected listbox item, nothing happens. Here is my code and thanks in advance for any help you can provide:
Private Sub ListBox1_Change()
Dim i As Long
With Me.ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
'Copy selected data to the specified text boxes
Call Copy_ListBox1_Data
'Run the Solver
Call Solver_Vs
End If
Next i
End With
End Sub
If I remove the Call Solver_Vs from the code, the Copy macro works fine when the listbox selection changes any number of times. If I create a command button to call the Solver_Vs, it will perform as desired every time I click the command button. So this makes me believe something is wrong in my For & if statement. Thoughts?
Bookmarks