I have two multi select listboxes in a userform in VBA in Excel.
One contains countries, the other contains cities.
If the user clicks and selects/deselects a country, I would like my script to automatically select/deselect all of the cities located in that country in the second listbox.
Equally, I would like that if the user clicks and selects/deselects a city, it automatically updates the first listbox to highlight only countries for which all of their corresponding cities are currently selected.
My problem is:
By using the OnChange event (OnClick is not available with multi select listboxes), each time either listbox is changed, it will change the other.
In this context, this means that any time a country is changed it will change all of the corresponding cities in the second listbox - for each country the user is effectively limited to selecting all cities or none.
Is there to tell whether the listbox is being changed by the user or by the script? If not, does an alternative method exist which could meet my aim?
Thank you for reading.