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?
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.
Comments