ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to make Combo Boxes not duplicate options (https://www.excelbanter.com/excel-programming/394267-how-make-combo-boxes-not-duplicate-options.html)

Rusty

How to make Combo Boxes not duplicate options
 
If you pick the Atlanta option(in the VBA code below) when you go back and
re-open the combo box it relists all the options atleast three times or more.
Is there any way after you make a selection on a combo box to keep the
option from duplicating and only show the list of options once?


Private Sub ComboBox1_Change()
ComboBox1.AddItem ""
ComboBox1.AddItem "Atlanta"
ComboBox1.AddItem "Chicago"
ComboBox1.AddItem "Washington DC"
Sheets("Questionaire").Range("N7") = ComboBox1.Value

Dave Peterson

How to make Combo Boxes not duplicate options
 
Why would you add the items to the combobox in the _change event?

If this is in a userform, maybe you could use userform_initialize to populate
that combobox.

Rusty wrote:

If you pick the Atlanta option(in the VBA code below) when you go back and
re-open the combo box it relists all the options atleast three times or more.
Is there any way after you make a selection on a combo box to keep the
option from duplicating and only show the list of options once?

Private Sub ComboBox1_Change()
ComboBox1.AddItem ""
ComboBox1.AddItem "Atlanta"
ComboBox1.AddItem "Chicago"
ComboBox1.AddItem "Washington DC"
Sheets("Questionaire").Range("N7") = ComboBox1.Value


--

Dave Peterson


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com