kieran989
03-03-2017, 05:17 PM
Hi everyone,
I have a userform that contains 3 listboxes. This is userform1
To populate the listbox1 I click a commandbutton1 that takes me to a second userform (userform2). From here I select the data from another listbox4 (multiselect). Once I click the commmandbutton2 on userform2 it populates listbox1 with the selected data. It also adds lookup values to listbox2 based on the values added to listbox1 via a series of for loops.
This all works fine so far. Now I need Listbox3 to be populated based on selected data from Listbox 2. I have achieved this by making a Listbox2_change() routine and this also works well.
My problem is that it seems the listbox2_change event is triggered every time values are added to listbox2 when the CommandButton2 is clicked on userform2. I thought the solution would be to enclose the commandbutton2 routine with:
Application.EnableEvents = False
code...
Application.EnableEvents = True
But the listbox2_change event is still running? Does anyone know what I am doing wrong here?
Apologize if the wording is confusing....
list of objects
userform1
-listbox1
-listbox2 (multi select)
-listbox3 (multi select)
-commandbutton1
userform2
-listbox4 (multiselect)
-commandbutton2
I have a userform that contains 3 listboxes. This is userform1
To populate the listbox1 I click a commandbutton1 that takes me to a second userform (userform2). From here I select the data from another listbox4 (multiselect). Once I click the commmandbutton2 on userform2 it populates listbox1 with the selected data. It also adds lookup values to listbox2 based on the values added to listbox1 via a series of for loops.
This all works fine so far. Now I need Listbox3 to be populated based on selected data from Listbox 2. I have achieved this by making a Listbox2_change() routine and this also works well.
My problem is that it seems the listbox2_change event is triggered every time values are added to listbox2 when the CommandButton2 is clicked on userform2. I thought the solution would be to enclose the commandbutton2 routine with:
Application.EnableEvents = False
code...
Application.EnableEvents = True
But the listbox2_change event is still running? Does anyone know what I am doing wrong here?
Apologize if the wording is confusing....
list of objects
userform1
-listbox1
-listbox2 (multi select)
-listbox3 (multi select)
-commandbutton1
userform2
-listbox4 (multiselect)
-commandbutton2