excel vba, write textbox value to a sheet based upon combobox value -
i have userform
, userform1, multiple textboxes
, comboboxes
.
i want when user fills out textboxes , comboboxes information saved worksheet on next available row.
the worksheet in top row, row 1, has headers defining information held in each column. first 7 columns have information written them userform next 121 columns not have information written them userform.
for first 7 columns info be, date, line, pitch, devices completed, number of operators, , comments. info come either combobox selections or textbox inputs , saved same column. have part figured out.
for part having issue 121 other columns, columns have header code type of reject a, ab, abe, ect there 121 different reject codes.
on userform user select combobox reject code in textbox next input number of rejects code, combobox1=abe , textbox1=3. when user clicks save want sub take info date, line, pitch, devices completed, number of operators, , comments placed open row under columns a,b,c,d,e,f respectively sub evaluate if there rejects record @ combobox1 value , write corresponding text value on same row under appropriate column containing combobox1 header value. reject code combobox values populated based upon worksheet headers of 121 columns.
private sub commandbuttonsave_click() 'dec intg dim irow long dim ws worksheet set ws = worksheets("pc data") dim find1 range ''find first row in database irow = ws.cells(rows.count, 1).end(xlup).offset(1, 0).row ''pitch 1 entry ws .range("a" & irow) = dtpicker1.value .range("b" & irow) = comboboxline.value .range("c" & irow) = comboboxshift.value .range("d" & irow) = ("1") .range("e" & irow) = textbox1.value .range("f" & irow) = textbox2.value .range("g" & irow) = textbox9.value
this code takes care of first 7 textbox , combobox entries dont know how lookup reject code comboboxes , text boxes. appreciate help.
i have tried using .find cant seem work added abve code .find.
private sub commandbuttonsave_click() 'dec intg dim irow long dim ws worksheet set ws = worksheets("pc data") dim rng range ''find first row in database irow = ws.cells(rows.count, 1).end(xlup).offset(1, 0).row '' find location of combobox1 value on ws range of h1:dx1 ws set rng = .range("h1:dx1").find(what:=combobox1.value, lookin:=xlvalues, _ lookat:=xlwhole, searchorder:=xlbyrows, _ searchdirection:=xlnext) end ws .range("a" & irow) = dtpicker1.value .range("b" & irow) = comboboxline.value .range("c" & irow) = comboboxshift.value .range("d" & irow) = ("1") .range("e" & irow) = textbox1.value .range("f" & irow) = textbox2.value .range("g" & irow) = textbox9.value .range(rng & irow) = textbox3.value end
Comments
Post a Comment