check and compare value entered in combobox

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
626
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
I am using VBA in Excel 2010. I was wondering if there is a simple way to check to see if the value entered in the combobox matches the already populated value within the combobox.
Code:
Private Sub cmbMonth_Enter()     
With Me.cmbMonth
        .AddItem "January"
        .AddItem "February"
        .AddItem "March"
        .AddItem "April"
        .AddItem "May"
        .AddItem "June"
        .AddItem "July"
        .AddItem "August"
        .AddItem "September"
        .AddItem "October"
        .AddItem "November"
        .AddItem "December"
    End With
End Sub
As you can see, this combobox is populated with the values of the names of the months. What I would like to do is, if the user manually types in a month and misspells it, on exit, check and see if what they entered matches with what is in the combobox, if not display a message box.

Thank you.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Why not do it this way
Put this script in a Command Button:
Modify Combobox name
Code:
Private Sub CommandButton2_Click()
'Modified 5/31/18 4:02 AM EDT
Dim i As Long
For i = 1 To 12
    ComboBox4.AddItem Format(MonthName(i), "MMMM")
Next
End Sub
 
Upvote 0
If it's an activex control set the MatchEntry property to 1 - frmMatchEntryComplete
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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