Problems with ComboBox in a VB form

clasagu

New Member
Joined
Feb 3, 2006
Messages
11
Hi,
I made a Form in VB with 3 ComboBox. The Problem is that when I show the option list and select any alternative. After that when I open again the Button for show the alternatives, the list is repeated at the end of the original. In others words, How can I limited that??.......I wish a only list option in the ComboBox and in this time is gowing any time that i select an option for the list

Thanks for your help, and regards!!!!
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
How exactly have you populated the comboboxes?
 
Upvote 0
View here.....the actual codes in a combobox

that it´s an example of the combobox codes right now......


Private Sub ComboBox1_Change()

'ComboBox1.Clear

ComboBox1.AddItem "PLASTICO"

ComboBox1.AddItem "MADERA"

ComboBox1.AddItem "METAL"

ComboBox1.AddItem "VIDRIO"

ComboBox1.AddItem "PAPEL"


End Sub


.....you can see something wrong????....sorry but I haven´t so much experience in Visual Basic.....thanks
 
Upvote 0
Every time you make a selection in the combobox all those items will get added to it again.

If this is a userform then try using it's Initialize event.

Code:
Private Sub UserForm_Initialize()
'ComboBox1.Clear

ComboBox1.AddItem "PLASTICO"

ComboBox1.AddItem "MADERA"

ComboBox1.AddItem "METAL"

ComboBox1.AddItem "VIDRIO"

ComboBox1.AddItem "PAPEL" 
End Sub
Or uncomment this line.
Code:
'ComboBox1.Clear
 
Upvote 0
Re:norie

Thanks for your help but if I use Initialize Event the selection options in the Combobox is empty!!!!
And if I erase the fisrt line(Combobox1.Clear) I don´t have any posibility for write another options that be not in the pre-determinated list.......
If you have any extra comments, send me.........
Regards
 
Upvote 0
How exactly have you tried to use the Initialize event?
 
Upvote 0
for Norie

I just copy the text sended for you.....

Private Sub UserForm_Initialize()
'ComboBox1.Clear

ComboBox1.AddItem "PLASTICO"

ComboBox1.AddItem "MADERA"

ComboBox1.AddItem "METAL"

ComboBox1.AddItem "VIDRIO"

ComboBox1.AddItem "PAPEL"
End Sub

In other words, I change the first line since
"Private Sub ComboBox1_Change()" to
"Private Sub ComboBox1_Initialize()".......

If your idea was different, explain me with details what need to do
One more time, thanks for your help.......
 
Upvote 0
You should have copied the code exactly as I posted it.

And it should go in the userform's module.

A combobox doesn't have an Initialize event.
 
Upvote 0
Ok Norie, tanks for your help!!!
Finally I solved my problem with a office´s friend who help me this time......
Thanks for all and regards...
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top