Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding items to ComboBox in a loop?


Using vb comboBox is it possible to add the same items to numerous
comboBox on the same sheet?
I have been trying the following....

Dim mycntrl As OLEObject
Dim sht As Worksheet
Set sht = ActiveSheet

For Each mycntrl In sht.OLEObjects

mycntrl.addItem "item1"

Next mycntrl

However I noticed that the addItem method is not available when trying
this, so how would you add an item in a loop?

thank you in advance for any help


--
cmpcwil2
------------------------------------------------------------------------
cmpcwil2's Profile: http://www.excelforum.com/member.php...o&userid=33411
View this thread: http://www.excelforum.com/showthread...hreadid=538425

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Adding items to ComboBox in a loop?

cmpcwil2,

This syntax is difficult for me to remember, but I think this is what you
want:

Dim mycntrl As OLEObject
Dim sht As Worksheet

Set sht = ActiveSheet
For Each mycntrl In sht.OLEObjects
If TypeOf mycntrl.Object Is ComboBox Then
mycntrl.Object.AddItem "item1"
End If
Next mycntrl

hth,

Doug


"cmpcwil2" wrote in
message ...

Using vb comboBox is it possible to add the same items to numerous
comboBox on the same sheet?
I have been trying the following....

Dim mycntrl As OLEObject
Dim sht As Worksheet
Set sht = ActiveSheet

For Each mycntrl In sht.OLEObjects

mycntrl.addItem "item1"

Next mycntrl

However I noticed that the addItem method is not available when trying
this, so how would you add an item in a loop?

thank you in advance for any help


--
cmpcwil2
------------------------------------------------------------------------
cmpcwil2's Profile:
http://www.excelforum.com/member.php...o&userid=33411
View this thread: http://www.excelforum.com/showthread...hreadid=538425



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Adding items to ComboBox in a loop?

Dim mycntrl As OLEObject
Dim sht As Worksheet
Set sht = ActiveSheet

For Each mycntrl In sht.OLEObjects
if typeof mycntrl.object is MSforms.Combobox then
mycntrl.Object.addItem "item1"
end if

Next mycntrl

--
Regards,
Tom Ogilvy


--
Regards,
Tom Ogilvy



"cmpcwil2" wrote:


Using vb comboBox is it possible to add the same items to numerous
comboBox on the same sheet?
I have been trying the following....

Dim mycntrl As OLEObject
Dim sht As Worksheet
Set sht = ActiveSheet

For Each mycntrl In sht.OLEObjects

mycntrl.addItem "item1"

Next mycntrl

However I noticed that the addItem method is not available when trying
this, so how would you add an item in a loop?

thank you in advance for any help


--
cmpcwil2
------------------------------------------------------------------------
cmpcwil2's Profile: http://www.excelforum.com/member.php...o&userid=33411
View this thread: http://www.excelforum.com/showthread...hreadid=538425


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding items to ComboBox in a loop?


Thank you for you help


--
cmpcwil2
------------------------------------------------------------------------
cmpcwil2's Profile: http://www.excelforum.com/member.php...o&userid=33411
View this thread: http://www.excelforum.com/showthread...hreadid=538425

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
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
Adding items to a ComboBox in Excel VBA Glenn Speed Excel Programming 1 August 5th 04 07:25 AM
Adding Items to a ListBox-Unique Items Only jpendegraft[_14_] Excel Programming 2 May 2nd 04 02:27 AM
Adding Items To Active X ComboBox on Sheet Dan Gesshel Excel Programming 3 October 20th 03 01:02 PM
adding items to combobox using "Tag" control to limit bob cochran Excel Programming 5 September 10th 03 05:21 PM


All times are GMT +1. The time now is 09:57 PM.

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

About Us

"It's about Microsoft Excel"