excel - Listbox AddItem Error -


i having problems getting list box work in vba. i'm not sure step missing. have created listbox called listbox1.

i wrote program follows:

sub listbox1_change()     dim listbox object      listbox1         .additem = "yes"         .additem = "no"     end end sub 

the program fails @ .additem = "no" line. object variable or block variable not set error.

not sure why adding items same listbox in change event. there syntax error in code. there no = when add item listbox. see this.

with listbox1     .additem "yes"     .additem "no" end 

also remove line dim listbox object. not need it.

if planning add listbox think need this

sub listbox1_change()     listbox2 '<~~ replace other listbox name         .additem "yes"         .additem "no"     end end sub 

Comments