Combo box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a variable named WhichCombo. This has a name of a combo box it in to
be used in the statment below.
When I try this there is an error. How do I use the variable in the
statment below for the combo box?

Sheets("Sheet1").WhichCombo.AddItem Item
 
I used a combobox from the Control Toolbox toolbar. Is that what you used?

Option Explicit
Sub testme02()

Dim WhichCombo As String
Dim myItem As String
WhichCombo = "Combobox1"

myItem = "hi there"

Worksheets("Sheet1").OLEObjects(WhichCombo).Object.AddItem myItem
End Sub

Item looks too much like VBA's .Item property. I wouldn't use it as a variable
name.
 
Yep thats what I needed.

Dave Peterson said:
I used a combobox from the Control Toolbox toolbar. Is that what you used?

Option Explicit
Sub testme02()

Dim WhichCombo As String
Dim myItem As String
WhichCombo = "Combobox1"

myItem = "hi there"

Worksheets("Sheet1").OLEObjects(WhichCombo).Object.AddItem myItem
End Sub

Item looks too much like VBA's .Item property. I wouldn't use it as a variable
name.
 

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

Similar Threads

Combo Box 1
Combo Box/Drop down box 1
combo box 2
Graph linked with combo boxes 2
Combo Box dropdown data 20
Add a combo box 1
Combo box range change 5
how do I load combo box from Excel columns? 1

Back
Top