Vba: SOLVING COMBOBOX -
basically have 2 combobox in userform using vba language. problem want display data automatically in combobox2 based on user selection in combobox 1. suggestion vba language?
private sub userform_initialize() dim student() variant range("a2").select range(selection, selection.end(xldown)).select student = selection me.combobox1.list = student end sub
here basics kind of linked choices :
your code, without useless (and greedy) .select
, better way last used row , assigning range array .value
:
private sub userform_initialize() dim student() variant student = range(range("a2"), range("a" & rows.count).end(xlup)).value me.combobox1.list = student end sub
and there part you'll need work on :
when change value of the combobox1
, it'll launch code, need refresh in there values proposed in combobox2
own tests, have no clue of doing.
private sub combobox1_change() dim restrictedchoices() me.combobox2.clear 'clear added elements me.combobox2.value=vbnullstring 'set active value empty string '------here need tests------- 'if me.combobox1.value<> ?? 'else me.combobox2.additem "array filled or item, after test on me.combobox1.value" 'end if end sub
Comments
Post a Comment