excel - VBA to show result based on combobox value changed -
i userform this:
i have few criteria meet. 1. different customer have different process , specification 2. if id#(textbox1) empty, process , specification change well. 3. different customer use different g-chip carry out progress.
as below code:
private sub userform_initialize()combobox1.list = array("apple", "banana", "watermelon") end sub private sub textbox1_change() call cual if textbox1.value = "n/a" call custxptarray else call custwithptaluarray end if end sub sub custwithptalu() select case combobox1 case "apple" combobox2.list = array("ni", "nini") case "banana" combobox2.list = array("au", "auau") case "watermelon" combobox2.list = array("pd", "pdpd") end select end sub sub custwithptaluarray() call custwithptalu if combobox1.text = "apple" textbox2.value = iif(combobox2.value = "ni", "10s", "20s") else if combobox1.text = "banana" textbox2.value = iif(combobox2.value = "au", "30s", "40s") else textbox2.value = iif(combobox2.value = "pd", "50s", "60s") end if end if end sub sub cual() select case combobox1 case "apple" combobox3.list = array("cu", "al") case "banana" combobox3.list = array("cu") case "watermelon" combobox3.list = array("al") end select end sub sub custxpt() combobox2.list = array("ni", "niau", "nipd", "nipdau") end sub sub custxptarray() call custxpt select case combobox2 case "ni" textbox2.value = "70s" case "niau" textbox2.value = "80s" case "nipd" textbox2.value = "90s" case "nipdau" textbox2.value = "100s" end select end sub
when try run code, specification not change. stay same number.
i have no idea, how happen when have set function 1 one.
customer: combobox1 id#: textbox1 g-chip:combobox3 plating type:combobox2 lower range:textbox2
all have done here put logic form calculations in "calc_form" , called whenever field changed, in either textbox1/combobox2/combobox3. may want think clearing values combobox's when criteria changes, force user recheck
private sub combobox2_change() calc_form end sub private sub combobox3_change() calc_form end sub private sub textbox1_change() calc_form end sub sub calc_form() call cual if textbox1.value = "n/a" call custxptarray else call custwithptaluarray end if end sub private sub userform_initialize() combobox1.list = array("apple", "banana", "watermelon") end sub sub custwithptalu() select case combobox1 case "apple" combobox2.list = array("ni", "nini") case "banana" combobox2.list = array("au", "auau") case "watermelon" combobox2.list = array("pd", "pdpd") end select end sub sub custwithptaluarray() call custwithptalu if combobox1.text = "apple" textbox2.value = iif(combobox2.value = "ni", "10s", "20s") else if combobox1.text = "banana" textbox2.value = iif(combobox2.value = "au", "30s", "40s") else textbox2.value = iif(combobox2.value = "pd", "50s", "60s") end if end if end sub sub cual() select case combobox1 case "apple" combobox3.list = array("cu", "al") case "banana" combobox3.list = array("cu") case "watermelon" combobox3.list = array("al") end select end sub sub custxpt() combobox2.list = array("ni", "niau", "nipd", "nipdau") end sub sub custxptarray() call custxpt select case combobox2 case "ni" textbox2.value = "70s" case "niau" textbox2.value = "80s" case "nipd" textbox2.value = "90s" case "nipdau" textbox2.value = "100s" end select end sub
Comments
Post a Comment