vba - Excel userform - not reading or writing to the spreadsheet -
i have created new userform writes data spreadsheet , using drop down load data form edit , re-save. when click save not write spreadsheet , when pre-populate spreadsheet not load userform. have below code works similar userform not work new 1 compiling. no error messages when running. missing?
dim notnow boolean dim dropbuttonclicked boolean private sub cmd_submit_click() 'submit dim emptyrow long 'make sheet1 active sheet1.activate 'determine emptyrow emptyrow = worksheetfunction.counta(range("a:a")) + 1 dim rowcount long dim ctl control ' inputs new project if no ref selected if me.cbosearch.value = "" application.screenupdating = false on error goto withref activesheet if .autofiltermode .showalldata end if end else ' if search selected edit line of data notnow = true application.screenupdating = false ' unprotects report on error goto withref activesheet if .autofiltermode .showalldata end if end withref: worksheets("sheet1").activate if me.cbosearch.value = "" n = worksheetfunction.counta(range("a:a")) + 1 else n = application.match(me.cbosearch.value, range("a:a"), 0) end if on error goto contnow 'transfer information cells(n, 1).value = log_no.value cells(n, 2).value = statement.value cells(n, 3).value = raised_by.value cells(n, 4).value = format(raised_date.value, "mm/dd/yyyy") cells(n, 5).value = action.value cells(n, 6).value = act_owner.value cells(n, 7).value = rel_ph.value cells(n, 8).value = cat.value cells(n, 9).value = status.value cells(n, 10).value = pos_neg.value cells(n, 11).value = format(trans_date.value, "mm/dd/yyyy") cells(n, 12).value = ref.value contnow: ' clear data form each ctl in me.controls if typename(ctl) = "textbox" or typename(ctl) = "combobox" or typename(ctl) = "dtpicker" ctl.value = "" elseif typename(ctl) = "checkbox" ctl.value = false end if next ctl ' save , return normal mode application.screenupdating = true 'activeworkbook.save unload me project_ll_form.show vbmodeless exit sub end if end sub private sub cmd_close_click() unload me end sub private sub cbosearch_change() if notnow exit sub 'if ref blank clear data form if me.cbosearch.value = "" unload me project_ll_form.show vbmodeless else ' bring in data based on ref in ref range vrange = "log" worksheets("sheet1").activate n = application.match(me.cbosearch.value, range("a:a"), 0) on error goto contkh 'transfer information form 'project information transfer log_no.value = cells(n, 1).value statement.value = cells(n, 2).value raised_by.value = cells(n, 3).value raised_date.value = format(cells(n, 4).value, "mm/dd/yyyy") action.value = cells(n, 5).value act_owner.value = cells(n, 6).value rel_ph.value = cells(n, 7).value cat.value = cells(n, 8).value status.value = cells(n, 9).value pos_neg.value = cells(n, 10).value trans_date.value = format(cells(n, 11).value, "mm/dd/yyyy") ref.value = cells(n, 12).value contkh: end if end sub
Comments
Post a Comment