excel - Return on Textbox1 value based upon two criterias in combobox and label -
hope u're well. need expert after trying lot without sucess, please.
i have price list in sheet1 3 columns:
medical procedure
type
value of procedure
in userform, need return in textbox1 value of procedure based on criteria selected in combobox1 (with values can found in medical procedure column in sheet1) , caption in label1 (wich alrealdy populated value can encounter in type column in sheet1).
i tried found here in stackoverflow user b hart (thanks, b hart!), wasn't able change return in textbox numerical value (this vba insert found value in listbox instead). issue criteria below in 2 combobox. need 2 criterias in combobox , in label.
private sub getcondstrandvalue() dim irow long dim strvalue string strvalue = vbnullstring if me.combobox1.value = vbnullstring or me.combobox2.value = vbnullstring exit sub planilha1 irow = 2 .range("a65536").end(xlup).row if strcomp(.cells(irow, 1).value, me.combobox1.value, 1) = 0 , _ strcomp(.cells(irow, 2).value, me.combobox2.value, 1) = 0 strvalue = .cells(irow, 3).value exit end if next end if strvalue = vbnullstring exit sub me.listbox1 'if want single value in listbox un-comment .clear line 'otherwise, values continue added '.clear .additem strvalue .value = strvalue .setfocus end end sub
maybe this:
private sub combobox1_change() dim lastrow integer lastrow = cells(rows.count, 1).end(xlup).row me r = 2 lastrow if sheets("sheet1").cells(r, 1) = .combobox1.value , sheets("sheet1").cells(r, 2) = .label1.caption .textbox1.text = sheets("sheet1").cells(r, 3) exit end if next end end sub
Comments
Post a Comment