Excel VBA Userform - How do I add a value to a combo box from a list in the userform?

StackOverflow https://stackoverflow.com/questions/21983801

  •  15-10-2022
  •  | 
  •  

سؤال

Is there a way to do the following:?

I would like a manual text box that when filled in and the user clicks "Add" and it adds the value to the combo box. However, I will also have this list stored somewhere so that the next time the user loads the form they can select "Previously Used" items from a list and these will then also be added to the combo box.

I will be adding a button to "Add all" of the previous items but it must still have the option to add items manually each time.

Even more useful would be to have an option to check items in and out of the combo box as well as the manually text input option.

I tried to add an image I found to better explain this but I need 10 rep points. Therefore, I hope this makes sense but please feel free to comment for more details and a better explanation if needed.

Link to an example of what I am thinking of but without the manual addition field:

http://kb.blackboard.com/download/attachments/14057766/bbui_multi_select.gif?version=1&modificationDate=1202823953747

هل كانت مفيدة؟

المحلول

Use this

combobox1.additem txtValue.Text

Sheets("SheetName").Cells(lastRow+1,col).value=txtValue.Text

Also add below code in Form_activate

For i=1 to lastrow
combobox1.additem Sheets("SheetName").Cells(i,col).value

next i
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top