Select next item from combobox and click on a button Excel VBA -


have combobox & command button placed on excel sheet. combobox have items listed, have 1, 2, 3, 4, 5. when combobox loaded first time, default first value ie 1 selected.

now using vba macro, want select next value combobox list (ie 2) , click on command button.

i googled unfortunately, not getting expecting.

here have far, dont expecting (explained above): getting error message object doesn't support property or method on line if worksheets("qc update").combobox1.selectedindex < combobox1.items.count - 1 then

sub select_next_items()    if isempty(range("a9").value) = true      if worksheets("qc update").combobox1.selectedindex < combobox1.items.count - 1        combobox1.listindex = 0 ' select first item in listbox        combobox1.listindex = combobox1.listcount - 1 ' selects last item        set combobox1.selectedindex = worksheets("qc update").combobox1.selectedindex + 1        set combobox1.listcount = 0      end if        end if  end sub 

hope guys don't feel offended here, have more clearer , more straight forward answer.

combobox1.listindex = combobox1.listindex +1 

here more complete ones. have take account when @ end of list therefore

if combobox1.listindex = combobox1.listcount -1    combobox1.listindex =1   else    combobox1.listindex = combobox1.listindex +1 

i hope reply helpful of new vba , need use urgently.

this simple understand if have solid background on programming in c++ / java


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -