excel - MultiSelection Listbox Userform -


i have multiselection listbox option style (chk boxes left). have below code transfer selected data worksheet (this must dynamic since listbox fed dynamic named range).

private sub cmdrun_click()  dim integer  = 0  while < lstproperties.listcount + 1     if lstproperties.selected(i) = true     sheet7.cells(i + 1, 1) = lstproperties.list(i)     end if     = + 1 loop  end sub 

it seems wants work think when run command unselecting list box data after first loop , therefore transposing first selection in list box.

does know how avoid this?

you'll need separate variable row reference can increment when item listbox selected...

private sub cmdrun_click()  dim rw integer dim integer  sheet7.columns(1).clearcontents  rw = 1 = 0 while < lstproperties.listcount     if lstproperties.selected(i) = true         sheet7.cells(rw, 1) = lstproperties.list(i)         rw = rw + 1     end if     = + 1 loop  end sub 

Comments