Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Add Item To ActiveX ComboBox

I want to add an item to an activeX combobox that is located on a
worksheet. Note this is not the combbox from the forms toolbar, and
its not the combobox inside of userforms, its the control toolbox
combobox.

I'm getting an object doesn't support this property error when I try
the following:

Sub PopulateList()
Worksheets("Sheet1").ComboBox1.Items.Add ("Item1")
End Sub

How do I add an item to this combobox? I don't want to use the
ListFillRange property b/c I will be putting this inside of a loop.

Thanks in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Add Item To ActiveX ComboBox

Sub test()
Dim cbo As msforms.ComboBox
Dim i As Long

ReDim arr(0 To 5 - 1) As String

For i = 1 To UBound(arr) + 1
arr(i - 1) = CStr(i * 11)
Next

' could reference like this
Set cbo = Worksheets("Sheet1").ComboBox1

' but this gives more flexibility
Set cbo = Worksheets("Sheet1").OLEObjects("ComboBox1").Objec t

'assign entire array (replacing existing)
cbo.List = arr

' add a new 3rd item (1st item is index-0)
cbo.AddItem "abc", 2

' add an item at the end
cbo.AddItem "xyz"

End Sub


Regards,
Peter T


"Daniel Jones" wrote in message
...
I want to add an item to an activeX combobox that is located on a
worksheet. Note this is not the combbox from the forms toolbar, and
its not the combobox inside of userforms, its the control toolbox
combobox.

I'm getting an object doesn't support this property error when I try
the following:

Sub PopulateList()
Worksheets("Sheet1").ComboBox1.Items.Add ("Item1")
End Sub

How do I add an item to this combobox? I don't want to use the
ListFillRange property b/c I will be putting this inside of a loop.

Thanks in advance!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Add Item To ActiveX ComboBox

Sheets("Sheet1").ComboBox1.AddItem ("Item1")
--
HTH...

Jim Thomlinson


"Daniel Jones" wrote:

I want to add an item to an activeX combobox that is located on a
worksheet. Note this is not the combbox from the forms toolbar, and
its not the combobox inside of userforms, its the control toolbox
combobox.

I'm getting an object doesn't support this property error when I try
the following:

Sub PopulateList()
Worksheets("Sheet1").ComboBox1.Items.Add ("Item1")
End Sub

How do I add an item to this combobox? I don't want to use the
ListFillRange property b/c I will be putting this inside of a loop.

Thanks in advance!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Add Item To ActiveX ComboBox

On Aug 27, 5:18*pm, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com wrote:
Sheets("Sheet1").ComboBox1.AddItem ("Item1")
--
HTH...

Jim Thomlinson

"Daniel Jones" wrote:
I want to add an item to an activeX combobox that is located on a
worksheet. *Note this is not the combbox from the forms toolbar, and
its not the combobox inside of userforms, its the control toolbox
combobox.


I'm getting an object doesn't support this property error when I try
the following:


Sub PopulateList()
Worksheets("Sheet1").ComboBox1.Items.Add ("Item1")
End Sub


How do I add an item to this combobox? *I don't want to use the
ListFillRange property b/c I will be putting this inside of a loop.


Thanks in advance!


This is awesome - thanks guys! How would I go about deleting all of
the items in the combo box? I figured out how to delete one at a time
but couldn't figure out how to delete all.

Thanks!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Add Item To ActiveX ComboBox

Thanks! How would I go about deleting all of the items in the
combobox? I could only discover how to delete one at a time like so

Worksheets("Sheet1").ComboBox1.RemoveItem (0)

On Aug 27, 5:18*pm, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com wrote:
Sheets("Sheet1").ComboBox1.AddItem ("Item1")
--
HTH...

Jim Thomlinson

"Daniel Jones" wrote:
I want to add an item to an activeX combobox that is located on a
worksheet. *Note this is not the combbox from the forms toolbar, and
its not the combobox inside of userforms, its the control toolbox
combobox.


I'm getting an object doesn't support this property error when I try
the following:




Sub PopulateList()
Worksheets("Sheet1").ComboBox1.Items.Add ("Item1")
End Sub


How do I add an item to this combobox? *I don't want to use the
ListFillRange property b/c I will be putting this inside of a loop.


Thanks in advance!




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Add Item To ActiveX ComboBox

Try this...

Worksheets("Sheet1").ComboBox1.Clear

--
Rick (MVP - Excel)


"Daniel Jones" wrote in message
...
Thanks! How would I go about deleting all of the items in the
combobox? I could only discover how to delete one at a time like so

Worksheets("Sheet1").ComboBox1.RemoveItem (0)

On Aug 27, 5:18 pm, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com wrote:
Sheets("Sheet1").ComboBox1.AddItem ("Item1")
--
HTH...

Jim Thomlinson

"Daniel Jones" wrote:
I want to add an item to an activeX combobox that is located on a
worksheet. Note this is not the combbox from the forms toolbar, and
its not the combobox inside of userforms, its the control toolbox
combobox.


I'm getting an object doesn't support this property error when I try
the following:




Sub PopulateList()
Worksheets("Sheet1").ComboBox1.Items.Add ("Item1")
End Sub


How do I add an item to this combobox? I don't want to use the
ListFillRange property b/c I will be putting this inside of a loop.


Thanks in advance!


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Add Item To ActiveX ComboBox

On Aug 28, 12:19*am, "Rick Rothstein"
wrote:
Try this...

Worksheets("Sheet1").ComboBox1.Clear

--
Rick (MVP - Excel)

"Daniel Jones" wrote in message

...
Thanks! How would I go about deleting all of the items in the
combobox? I could only discover how to delete one at a time like so

Worksheets("Sheet1").ComboBox1.RemoveItem (0)

On Aug 27, 5:18 pm, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-

This-.com wrote:
Sheets("Sheet1").ComboBox1.AddItem ("Item1")
--
HTH...


Jim Thomlinson


"Daniel Jones" wrote:
I want to add an item to an activeX combobox that is located on a
worksheet. Note this is not the combbox from the forms toolbar, and
its not the combobox inside of userforms, its the control toolbox
combobox.


I'm getting an object doesn't support this property error when I try
the following:


Sub PopulateList()
Worksheets("Sheet1").ComboBox1.Items.Add ("Item1")
End Sub


How do I add an item to this combobox? I don't want to use the
ListFillRange property b/c I will be putting this inside of a loop.


Thanks in advance!


Thanks! is this supposed to work with an activex combo box (from
control toolbox)? in the help file it says "This method will fail if
it's applied to a built-in command bar control."

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Add Item To ActiveX ComboBox

Thanks! is this supposed to work with an activex combo
box (from control toolbox)? in the help file it says "This
method will fail if it's applied to a built-in command bar
control."


You could always try any suggestions given to you on a newsgroup... that is
usually faster than posting a question and waiting for an answer. Yes, this
code works on a ComboBox from the Control Toolbox toolbar.

--
Rick (MVP - Excel)


"Daniel Jones" wrote in message
...
On Aug 28, 12:19 am, "Rick Rothstein"
wrote:
Try this...

Worksheets("Sheet1").ComboBox1.Clear

--
Rick (MVP - Excel)

"Daniel Jones" wrote in message

...
Thanks! How would I go about deleting all of the items in the
combobox? I could only discover how to delete one at a time like so

Worksheets("Sheet1").ComboBox1.RemoveItem (0)

On Aug 27, 5:18 pm, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-

This-.com wrote:
Sheets("Sheet1").ComboBox1.AddItem ("Item1")
--
HTH...


Jim Thomlinson


"Daniel Jones" wrote:
I want to add an item to an activeX combobox that is located on a
worksheet. Note this is not the combbox from the forms toolbar, and
its not the combobox inside of userforms, its the control toolbox
combobox.


I'm getting an object doesn't support this property error when I try
the following:


Sub PopulateList()
Worksheets("Sheet1").ComboBox1.Items.Add ("Item1")
End Sub


How do I add an item to this combobox? I don't want to use the
ListFillRange property b/c I will be putting this inside of a loop.


Thanks in advance!


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
publish activeX combobox and other activeX control irene c Excel Programming 0 March 19th 07 07:19 AM
How to display the first Item in a combobox as the default item Nigel Excel Programming 2 December 8th 06 10:21 PM
How to display the first Item in a combobox as the default item Jim Cone Excel Programming 0 December 8th 06 06:42 PM
ActiveX Control Item Numbers Mark Excel Programming 0 August 2nd 06 01:45 AM
ActiveX / C++ - Extra menu item Pixy Excel Programming 0 July 7th 04 02:51 PM


All times are GMT +1. The time now is 11:24 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"