Clear ComboBox selection

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
Office Version
  1. 2007
Platform
  1. Windows
Hi,
I have a ComboBox with 3 selections within it
Selection ONE TWO & THREE

I select TWO but i need a reset button.

This is my reset button code at present.
Rich (BB code):
Private Sub CommandButton1_Click()
UserForm_Initialize
End Sub

I wish to press the reset button and have the ComboBox empty like it was before i made the selection.

I have tried the following but it either gives me a compile error or its clears the combobox BUT just adds the same selections within the lis agin thus ONE THWO THREE ONE TWO THREE.
Rich (BB code):
ComboBox2.SelectedIndex = -1

ComboBox2.ResetText

ComboBox2.Text = " "

ComboBox2Text = Null



Please can you advise how i make it show nothing selected BUT just keep the same list of ONE TWO THREE
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
If you want to clear items in a combobox use Clear.
VBA Code:
ComboBox2.Clear
 
Upvote 0
Solution
Hi,
I think I did try

ComboBox2.Clear

But that also didn’t work.

Is the above written correctly ?
 
Upvote 0
How are you populating the combobox?
 
Upvote 0
How are you populating the combobox?

This is the code

Rich (BB code):
    Private Sub UserForm_Initialize()
        OptionButton1.Visible = False
        OptionButton2.Visible = False
        OptionButton3.Visible = False
        OptionButton4.Visible = False
        OptionButton5.Visible = False
        OptionButton6.Visible = False
        ComboBox2.AddItem "FERRARI TYPE"
        ComboBox2.AddItem "HYUNDAI FOB"
        ComboBox2.AddItem "ORIGINAL 2B"
        Label8.Visible = False
        Label9.Visible = False
        End Sub

When i use the following Yes it clears the incorrectly selected text but when i then click on the drop down the ONE TWO THREE isnt there.
I need to close then open the form again.

Rich (BB code):
Private Sub CommandButton1_Click()
UserForm_Initialize
ComboBox2.Clear
End Sub
 
Upvote 0
I don't now what you mean about "ComboBox2.SelectedIndex = -1".
Did you mean you have try "ComboBox2.ListIndex = -1"?
I suggest to remove old combobox controls and replace with new with default properties.
"ComboBox2.ListIndex = -1" do the job.
 
Upvote 0
Thanks but that just added to the list so making everythiung there twice.
BUT this worked.

Rich (BB code):
Private Sub CommandButton1_Click()
ComboBox2.Clear
UserForm_Initialize
End Sub
 
Upvote 0
If all you want to do is clear what's entered/selected in the combobox use this.
VBA Code:
ComboBox2.Value = ""
 
Upvote 0
Thanks.
I looked again using clear one you mentioned but swapped it around with the initialise code and it works.
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,937
Members
449,094
Latest member
teemeren

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