i have 2 multi select listboxes in userform in vba in excel.
one contains countries, other contains cities.
if user clicks , selects/deselects country, script automatically select/deselect of cities located in country in second listbox.
equally, if user clicks , selects/deselects city, automatically updates first listbox highlight countries of corresponding cities selected.
my problem is:
by using onchange event (onclick not available multi select listboxes), each time either listbox changed, change other.
in context, means time country changed change of corresponding cities in second listbox - each country user limited selecting cities or none.
is there tell whether listbox being changed user or script? if not, alternative method exist meet aim?
thank reading.
application.enableevents doesn't have effect on userform objects.
what need form scoped variable (best way adding custom property) store , manipulate form's event state.
see example , re-work code along this, example checkbox same logic applies listbox, combobox etc...
'/ userform 2 checkboxes : checkbox1 , checkbox2 private m_bevents boolean public property let enableformevents(bval boolean) m_bevents = bval end property public property enableformevents() boolean enableformevents = m_bevents end property private sub checkbox1_click() '/ custom event status me.enableformevents = false me.checkbox2 = me.checkbox1 me.enableformevents = true end sub private sub checkbox2_click() if me.enableformevents msgbox "check box clicked user." else msgbox "check box clicked code." end if end sub
Comments
Post a Comment