Limit users to combobox list

MFish

Board Regular
Joined
May 9, 2019
Messages
71
I have the property set to, "Match Required" for my comboboxes. I have a clear button that resets all of the values of my comboboxes to nothing, "". It keeps saying the selection is invalid after the clear button is pressed. I'll then fill out the form with the correct information and I'll hit submit, or just exit the userform, and the same message prompts me. How do I get this to stop popping up after the clear button is used or moving forward?
 

Kamolga

Well-known Member
Joined
Jan 28, 2015
Messages
1,157
Maybe
Code:
[LEFT][COLOR=#000000][FONT=monospace]Application.DisplayAlerts = [/FONT][/COLOR][COLOR=#07704A][FONT=monospace]False[/FONT][/COLOR][COLOR=#000000][FONT=monospace] [/FONT][/COLOR][/LEFT]
 

MFish

Board Regular
Joined
May 9, 2019
Messages
71
Well, I still need the alerts to display if something is accidentally left blank. Any other way?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
32,315
Office Version
365
Platform
Windows
You can do something like
Code:
[COLOR=#ff0000]Dim DisableEvents As Boolean[/COLOR]

Private Sub ComboBox2_Change()
   If DisableEvents Then Exit Sub
   'your code here
End Sub

Private Sub CommandButton1_Click()
   DisableEvents = True
   'your code here
   DisableEvents = False
End Sub
The line in red needs to go at the very top of the module, before any code.
 

Kamolga

Well-known Member
Joined
Jan 28, 2015
Messages
1,157
Create your MsgBox if something is left blank with focus to that place, so as a user you do not even need to look what is wrong...or simply use
Code:
[FONT=monospace]Application.DisplayAlerts = [/FONT][COLOR=#07704a][COLOR=#07704a][FONT=monospace][FONT=monospace]True[/FONT][/FONT][/COLOR][/COLOR]
after your line
 
Last edited:

Forum statistics

Threads
1,082,274
Messages
5,364,171
Members
400,785
Latest member
Mahar92

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top