Iterate combo box

  • Thread starter Thread starter inungh
  • Start date Start date
I

inungh

I would like to iterate combo box to get all result in a loop.

I try to use cmbMyCombo.count, but Excel does not support the
property.

Are there any property that I can access for this iterate combo box?

Your information is great appreciated,
 
Try something like the following. ListCount returns the number of
items in the list. These are 0-based, so the first item is 0, the
second is 1, up though the last item at ListCount-1.

Dim CBX As MSForms.ComboBox
Dim N As Long
Set CBX = combobox1
For N = 0 To CBX.ListCount - 1
Debug.Print N, CBX.List(N)
Next N


Set the CBX variable to your combobox.

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
Try this
Private Sub CommandButton1_Click()
For i = 1 To ComboBox1.ListCount - 1
MsgBox Me.ComboBox1.List(i)
Next
End Sub
 
For i = 1 To ComboBox1.ListCount - 1

The i variable should start at 0 not 1.

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
Thanks Chip
That is why I am not an MVP, LOL. I would have figured it out if I had
tested the code before posting it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top