excel - ListBox not populating -


i beginner using vba in excel. trying come user form looks this. have coding in, when launch command button in excel, listbox not populate. when try enter in numbers , click "submit" "run-time error '424':object required". when click debug, takes me line

cells(emptyrow, 1).value = dotwlistbox.value

i not sure going on. appreciated!! here code:

private sub cancel_click()  unload me  end sub    private sub clear_click()  call userform1_initialize    end sub        private sub submit_click()  dim emptyrow long  'make sheet3 active  sheet3.activate  'determine emptyrow  emptyrow = worksheetfunction.counta(range("a:a")) + 1  'transfer information  cells(emptyrow, 1).value = dotwlistbox.value  cells(emptyrow, 2).value = t235tocbtextbox.value  cells(emptyrow, 3).value = t235codbtextbox.value  cells(emptyrow, 4).value = apiphbtextbox.value  cells(emptyrow, 5).value = apiturbiditybtextbox.value  cells(emptyrow, 6).value = apitocbtextbox.value  cells(emptyrow, 7).value = apicodbtextbox.value  cells(emptyrow, 8).value = apibodbtextbox.value  cells(emptyrow, 9).value = longbaydobtextbox.value  cells(emptyrow, 10).value = asudobtextbox.value  cells(emptyrow, 11).value = rasmlssbtextbox.value  cells(emptyrow, 12).value = clarifierturbiditybtextbox.value  cells(emptyrow, 13).value = clarifierphbtextbox.value  cells(emptyrow, 14).value = clarifiernh3btextbox.value  cells(emptyrow, 15).value = clarifierno3btextbox.value  cells(emptyrow, 16).value = clarifierenterococcibtextbox.value  cells(emptyrow, 17).value = clarifierphosphorusbtextbox.value          end sub    private sub userform1_initialize()  'empty t235tocbtextbox  t235tocb.value = ""  'empty t235codtextbox  t235codb.value = ""      'fill dotwlistbox  dotwlistbox  .additem "monday"  .additem "tuesday"  .additem "wednesday"  .additem "thursday"  .additem "friday"  end    'empty apiphbtextbox  aphiphb.value = "1"  'empty apiturbiditybtextbox  apiturbidityb.value = ""  'empty apitocbtextbox  apitocb.value = ""  'empty apicodbtextbox  apicodb.value = ""  'empty apibodbtextbox  apibodb.value = ""  'empty longbaydobtextbox  longbaydob.value = ""  'empty asudobtextbox  asudob.value = ""  'empty rasmlssbtextbox  rasmlssb.value = ""  'empty clarifierturbiditybtextbox  clarifierturbidityb.value = ""  'empty clarifierphbtextbox  clarifierphb.value = ""  'empty clarifiernh3btextbox  clarifiernh3b.value = ""  'empty clarifierno3btextbox  clarifierno3b.value = ""  'empty clarifierenterococcibtextbox  clarifierenterococcib.value = ""  'empty clarifierphosphorustextbox  clarifierphosphorusb.value = ""  end sub

there can 2 reasons:

  1. your listbox multiselect property set 1 (fmmultiselectmulti) or 2 (fmmultiselectextented)

    in case value property null

  2. your listbox has no item selected

    even if multiselect property set 0 (fmmultiselectsingle) value property return null if no item selected

    in case set check listindex property, follows

if dotwlistbox.listindex <> -1 cells(emptyrow, 1).value = dotwlistbox.value

since -1 value returned listindex property when no item selected