Combo Box initial set up

  • Thread starter Thread starter AJ Master
  • Start date Start date
A

AJ Master

I'd like to place a combo box on my worksheet, but I don't want to us
the rowsource property to populate the static dropdown list I need.
How can I set up the static values for the drop down list.

I am currently just using:

with combobox1
.additem " "
.additem "FULL"
.additem "NET"
.additme "MOD"
end with

Unfortunately whenever I use the ComboBox_Change() sub it keeps addin
the same items to the list and I go from 4 items to 8, then to 12
etc.... Any ideas on how I can just set the initial values with VB
without utilizing row source for the static list?

Thanks....A
 
Don't add the items in the Change event, do it from another separate macro.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Bob,

I'm not adding the items in the change event. I have a sub calle
"ComboBox_Initialize" that contains the additems method.

Any other thoughts why this is happening?

A
 
Sub ComboBox_Initialize()
combobox1.clear
' now add the items

End Sub
 
Hi,

Sub TEST() 'ComboBox_Initialize()

With ComboBox1
.Clear
.List = Array(" ", "FULL", "NET", "MOD")
End With

End Sub


--
Regards,
Soo Cheon Jheong
_ _
^ ^
~
 
Others have suggested Clear, but surely you are not repeatedly calling this
sub are you?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Thanks to all for your help. One last question.

When I open the workbook, the combobox is not populated, even though
the code is there. I would prefer not to run some macro to run the
"ComboBox_initialize" sub.

How can I make sure this combobox list is populated when I open the
workbook/template?

Thanks...again.

AJ
 
Add it to the Workbook_Open event in the Thisworkbook code module.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Bob,

I added the code to the workbook open event, but I received a compil
error. Would you mind giving me some sample code?

Thanks....A
 
AJ,

Here is some sample code

Private Sub Workbook_Open()

With Worksheets("Sheet1").ComboBox1
.AddItem "Item #1"
.AddItem "Item #2"
.AddItem "Item #3"
.AddItem "Item #4"
.AddItem "Item #5"
.AddItem "Item #6"
.ListIndex = 0
End With

End Sub

Make sure it is in the ThisWorkbook code module.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

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