ComboBox Restrictions

rhombus4

Well-known Member
Joined
May 26, 2010
Messages
586
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Have a few comboboxes on a form and have tried both options below which do work and restrict entries.

However what if I enter a dropdown by mistake and then decide I didn't want to and I want it to be cleared, it wont let me clear the selection.
The only workaround is possibly to add a space at the top of the named range so you could select that instead, but was wondering if there is an easy way maybe in the properties or something I could set at initialisation


Set MatchRequired to True - Allows you to type in the combo box, but limits the entry to the defined range.
Set Style property to fmStyleDropDownList - Can't type, but limits the entry to the defined range.

Not sure if there is a big difference between the two options or which one is the best
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hello

VBA Code:
Private Sub UserForm_Click()
Me.ComboBox1 = ""
End Sub

Private Sub UserForm_Initialize()
Me.CheckBox1.TabIndex = 0
Me.TEXT1.TabIndex = 1
Me.TextBox2.TabIndex = 2
Me.TextBox3.TabIndex = 3
Me.ComboBox1.Style = fmStyleDropDownList
Me.ComboBox1.List = Range("b14:b18").Value
End Sub
 
Upvote 0
You could just use the backspace to clear the entry
or you could use the double click event.
VBA Code:
Private Sub ComboBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    ComboBox1.ListIndex = -1
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,808
Messages
6,121,681
Members
449,048
Latest member
81jamesacct

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