Clear entry in combobox

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,644
Office Version
  1. 365
Platform
  1. Windows
Is there a way of disabling the ability to click into a combobox and clear the selected entry using the 'backspace/delete' key but still enabling the drop down RowSource to be used?

The RowSource for the combo box includes a 'blank' cell so this can be selected from the combobox if the selected entry needs to be removed, but I want the user to only use the drop down RowSource to select a 'blank' entry rather than clicking into the combo and deleting.

The reason for asking is because I am getting an 'Invalid Property Value' error at times and I think it may be to do with the combobox being cleared using backspace/delete and not selecting the 'blank' value from the RowSource.


Thanks
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Why do you have a blank item in the list?

Why not change it to something like 'Not applicable'?

Also I take it you've set match required to true/false? That'll be why you get the error message.

You could just check yourself if what's been entered/selected is on the list by looking at the ListIndex property of the combobox.

That should give you more control over what happens when an incorrrect selection/entry is made.

Perhaps even a customized message for the user.
 
Upvote 0
I need to have a blank cell in the RowSource as the user may not need to select an entry and if one is selected in error, they need to be able to remove by selecting the blank value of the RowSource.

I think even if I gave the option of 'N/a' for example, rather than a blank cell, some users would still delete the entry if entered in error and then not select 'N/a'.

The 'MatchRequired' is set to 'True' as I need the user to select an item from the RowSource rather than manually entering a value into the combo.

I'm not sure what you mean by the following
You could just check yourself if what's been entered/selected is on the list by looking at the ListIndex property of the combobox.

That should give you more control over what happens when an incorrrect selection/entry is made.

Perhaps even a customized message for the user.
but ince I understand, I'm willing to try it.


Thanks
 
Upvote 0
All I'm suggesting is that you check what the combobox's listindex is when it's exited.

If it's -1 then what's been entered isn't on the list.

You could also prevent them from typing in the combobox by setting the Style property to fmStyleDropDownList.
 
Upvote 0
Thanks Norie......just the simple solution I have been looking for for the past 3 days....:biggrin:

Changing the Style to a list rather than a combo is now preventing the erro but still allowing the user to select a blank even by deleting the value from the combo.


Thanks again
 
Upvote 0
Glad it worked but still a bit confused about the blank thing, but if it's what you need...:)
 
Upvote 0

Forum statistics

Threads
1,224,568
Messages
6,179,595
Members
452,927
Latest member
whitfieldcraig

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