Excel VBA: Looping through a combo box's items from another user form

Hydes Yase

I want to loop through a combo box's items but not get their values. I just want to loop through how many items there are. Here is how I add items to it.

Private Sub UserForm_Initialize()

    Chapter.AddItem "Chapter 1"
    Chapter.AddItem "Chapter 2"
    Chapter.AddItem "Chapter 3"
    Chapter.AddItem "No Chapter"

End Sub

And this is what I tried on looping through it.

        Dim itm As Object

        For Each itm In UserForm.ComboBox1.Items.Count

        Next

But error prompt; Compile error: Method or data member not found

Does it matter that these codes aren't on one user form? I have two user forms and the adding of items to the combo box is on the second and the looping through the combo box is on the first one. Does that matter?

Chris Harper

If you only want to loop for items count, you can try

    Dim itm As Object

    For i = 1 to UserForm1.Chapter.ListCount

    Next

Where Userform1 is the name of the Form that contains Combobox and Chapter is the name of the ComboBox

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Selected value in combo box to open another worksheet in Excel VBA/User form

From Dev

Unselectable items in a Combo Box in an Excel VBA

From Dev

Excel VBA adding items to combo box without repeated items

From Dev

Excel VBA adding items to combo box without repeated items

From Dev

Combo Box in VBA Excel

From Dev

Selecting a value of a combo box if the user selects a value in another combo box

From Dev

Setting condition for the combo box in a user form

From Dev

Populate a combo box with a string array in a user form

From Dev

how to add value from one combo box to another combo box

From Dev

Assigning values to Combo box in excel VBA

From Dev

Assigning values to Combo box in excel VBA

From Dev

How to add items from combo box into array

From Dev

Combo Box to Another Combo Box

From Dev

How to add BOTH static values and records from a table as list items to a combo box in VBA

From Dev

Opening a combo box from another object

From Dev

Opening a combo box from another object

From Dev

Adding items from a database to a combo box and a text box

From Dev

Remove Items from Collection in a loop (Combo Box items)

From Dev

Excel VBA looping through select worksheets

From Dev

Looping through cell values in Excel VBA

From Dev

Combo Box with option that can only be selected programatically and not by the user in VBA Access

From Dev

Looping through GeoJSON items from GeoRSS with jQuery

From Dev

Looping through GeoJSON items from GeoRSS with jQuery

From Dev

Excel VBA: how to store combo box current value to cell

From Dev

Activate combo-box action on select value using Excel VBA

From Dev

Excel VBA Replace data validation lists with combo box

From Dev

Extjs how to remove and undo list items from extjs combo box

From Dev

How to send these items in the combo box

From Dev

Set items to Combo Box in JAVA

Related Related

  1. 1

    Selected value in combo box to open another worksheet in Excel VBA/User form

  2. 2

    Unselectable items in a Combo Box in an Excel VBA

  3. 3

    Excel VBA adding items to combo box without repeated items

  4. 4

    Excel VBA adding items to combo box without repeated items

  5. 5

    Combo Box in VBA Excel

  6. 6

    Selecting a value of a combo box if the user selects a value in another combo box

  7. 7

    Setting condition for the combo box in a user form

  8. 8

    Populate a combo box with a string array in a user form

  9. 9

    how to add value from one combo box to another combo box

  10. 10

    Assigning values to Combo box in excel VBA

  11. 11

    Assigning values to Combo box in excel VBA

  12. 12

    How to add items from combo box into array

  13. 13

    Combo Box to Another Combo Box

  14. 14

    How to add BOTH static values and records from a table as list items to a combo box in VBA

  15. 15

    Opening a combo box from another object

  16. 16

    Opening a combo box from another object

  17. 17

    Adding items from a database to a combo box and a text box

  18. 18

    Remove Items from Collection in a loop (Combo Box items)

  19. 19

    Excel VBA looping through select worksheets

  20. 20

    Looping through cell values in Excel VBA

  21. 21

    Combo Box with option that can only be selected programatically and not by the user in VBA Access

  22. 22

    Looping through GeoJSON items from GeoRSS with jQuery

  23. 23

    Looping through GeoJSON items from GeoRSS with jQuery

  24. 24

    Excel VBA: how to store combo box current value to cell

  25. 25

    Activate combo-box action on select value using Excel VBA

  26. 26

    Excel VBA Replace data validation lists with combo box

  27. 27

    Extjs how to remove and undo list items from extjs combo box

  28. 28

    How to send these items in the combo box

  29. 29

    Set items to Combo Box in JAVA

HotTag

Archive