Combobox Invalid Property Value

austin350s10

Active Member
Joined
Jul 30, 2010
Messages
321
I have a UserForm I am working on where the user is to make a selection from a dropdown style combo box. The problem I am having is I only want the user to be able to make a selection from the dropdown and not input there own value. I have set the property: Match Required to True.

Right now the user can input there own value but it returns the error MsgBox "Invalid Property Value". If the value there entered is not in the dropdown list.

Is there a way to intercept this error code and use my one error message or a way to block the user from adding there own values into the combo box?

Here is the only code I use to populate the combobox:
Code:
Private Sub UserForm_Initialize()
    Dim lMonth As Long
    For lMonth = 1 To 12
        Me.ComboBox1.AddItem Format(DateSerial(2000, lMonth, 1), "MMMM")
    Next lMonth
End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Rather than intercepting the error message, intercept the key entry.
Code:
Private Sub ComboBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    KeyAscii = 0
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,568
Messages
6,114,348
Members
448,570
Latest member
rik81h

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