Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Iterate combo box

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,



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Iterate combo box


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)


On Wed, 17 Dec 2008 08:08:25 -0800 (PST), inungh
wrote:

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,


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Iterate combo box

Try this
Private Sub CommandButton1_Click()
For i = 1 To ComboBox1.ListCount - 1
MsgBox Me.ComboBox1.List(i)
Next
End Sub

"inungh" wrote:

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,




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Iterate combo box

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)


On Wed, 17 Dec 2008 08:31:03 -0800, Mike
wrote:

Try this
Private Sub CommandButton1_Click()
For i = 1 To ComboBox1.ListCount - 1
MsgBox Me.ComboBox1.List(i)
Next
End Sub

"inungh" wrote:

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,




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Iterate combo box

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.


"Chip Pearson" wrote:

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)


On Wed, 17 Dec 2008 08:31:03 -0800, Mike
wrote:

Try this
Private Sub CommandButton1_Click()
For i = 1 To ComboBox1.ListCount - 1
MsgBox Me.ComboBox1.List(i)
Next
End Sub

"inungh" wrote:

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,







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Iterate combo box

On Dec 17, 5:04*pm, Mike wrote:
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.



"Chip Pearson" wrote:
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)


On Wed, 17 Dec 2008 08:31:03 -0800, Mike
wrote:


Try this
Private Sub CommandButton1_Click()
For i = 1 To ComboBox1.ListCount - 1
* MsgBox Me.ComboBox1.List(i)
Next
End Sub


"inungh" wrote:


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,- Hide quoted text -


- Show quoted text -


Thanks millions,

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sub to iterate thru combo box n copy paste n name ranges successively in a new sht Max Excel Programming 11 March 29th 08 03:25 PM
Sub to iterate thru combo box n copy paste n name ranges successively in a new sht Max Excel Programming 0 March 27th 08 03:30 AM
Iterate through a form RobEdgeler Excel Programming 2 September 17th 05 06:58 PM
Can't iterate thru a row with For peter Excel Programming 2 January 7th 05 04:46 AM
Newbie question: How to iterate over combo boxes on a worksheet Mark Shirley Excel Programming 0 November 2nd 04 05:28 AM


All times are GMT +1. The time now is 10:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"