excel - Setting Listbox Count Criteria across multiple listboxes -


i have tool building in excel end user produce interview form job interview, in order achieve have built series of questoins determine criteria of skills needed role, , skills translate questions relate skills. job interview questions selected limited 5 @ time.

i have code keeps track of how many listbox selections selected in single listbox, unfortunately due ux issue, have had re-design interface. have had produce multiple user forms own listbox, , each listbox produces list dynamic named range linked pivottable criteria. have idea of how track selections multiple listboxes? current code below worked single listbox.

private sub listbox1_change() dim counter         integer dim selectedcount   integer  selectedcount = 0  counter = 1 listbox1.listcount step 1     if listbox1.selected(counter - 1) = true         selectedcount = selectedcount + 1     end if next counter  if selectedcount >= 6     listbox1.selected(listbox1.listindex) = false     msgbox "pick 5 questions only", vbinformation + vbokonly, "retry:" end if  end sub 

so managed rewrite works across multiple listboxes located in different userforms, put code in userforms contained listboxes , works.

private sub listbox1_change() dim counter1 integer, counter2 integer, counter3 integer, counter4 integer, counter5 integer, counter6 integer, selectedcount integer selectedcount = 0  counter = 1 firstquestion.listbox1.listcount step 1     if firstquestion.listbox1.selected(counter - 1) = true         selectedcount = selectedcount + 1         if selectedcount >= 6             firstquestion.listbox1.selected(firstquestion.listbox1.listindex) = false             msgbox "pick 5 questions only", vbinformation + vbokonly, "retry:"             exit sub         end if     end if next counter  counter2 = 1 secondquestion.listbox1.listcount step 1     if secondquestion.listbox1.selected(counter2 - 1) = true         selectedcount = selectedcount + 1         if selectedcount >= 6             secondquestion.listbox1.selected(secondquestion.listbox1.listindex) = false             msgbox "pick 5 questions only", vbinformation + vbokonly, "retry:"             exit sub         end if     end if next counter2  counter3 = 1 thirdquestion.listbox1.listcount step 1     if thirdquestion.listbox1.selected(counter3 - 1) = true         selectedcount = selectedcount + 1         if selectedcount >= 6             thirdquestion.listbox1.selected(thirdquestion.listbox1.listindex) = false             msgbox "pick 5 questions only", vbinformation + vbokonly, "retry:"             exit sub         end if     end if next counter3  counter4 = 1 fourthquestion.listbox1.listcount step 1     if fourthquestion.listbox1.selected(counter4 - 1) = true         selectedcount = selectedcount + 1         if selectedcount >= 6             fourthquestion.listbox1.selected(fourthquestion.listbox1.listindex) = false             msgbox "pick 5 questions only", vbinformation + vbokonly, "retry:"             exit sub         end if     end if next counter4  counter5 = 1 fifthquestion.listbox1.listcount step 1     if fifthquestion.listbox1.selected(counter5 - 1) = true         selectedcount = selectedcount + 1         if selectedcount >= 6             fifthquestion.listbox1.selected(fifthquestion.listbox1.listindex) = false             msgbox "pick 5 questions only", vbinformation + vbokonly, "retry:"             exit sub         end if     end if next counter5  counter6 = 1 sixthquestion.listbox1.listcount step 1     if sixthquestion.listbox1.selected(counter6 - 1) = true         selectedcount = selectedcount + 1         if selectedcount >= 6             sixthquestion.listbox1.selected(sixthquestion.listbox1.listindex) = false             msgbox "pick 5 questions only", vbinformation + vbokonly, "retry:"             exit sub         end if     end if next counter6 end sub 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -