How to Prevent or Disable Typing in a Combo Box in Excel?


Microsoft Excel provides a spreadsheet tool which forms a component of Microsoft's Office suite of applications for businesses. Microsoft Excel could be used to set up, supervise, and calculate information in a spreadsheet. Whenever information is created or revised, researchers as well as other workers can make it easier to study by arranging it with programs like Excel. Excel contains many boxes known as cells which are organized in rows and columns. These cells hold information.

Common Excel Use Cases

Excel is primarily used in business settings. It is utilized for business assessment, personnel administration, management of operations, and profits reporting, among other applications. Excel uses a large array of organized cells to arrange and edit data as well as answer algebraic issues. Clients can gather information within the spreadsheet using graphing tools, pivoting charts, and equations. Visual Basic for Programs is a programming language used to create macros that is bundled with spreadsheet applications.

What Exactly is Data Validation?

Data Validation is a crucial Excel function that allows you to regulate or limit users' inputs/entries in specific cells. It allows users to define the validation criteria that govern what information they enter into the associated cells in an Excel sheet. For example, we can limit users to entering numbers between 1 and 10, usernames or passwords with fewer than 30 characters, entering or selecting an item from a specified list of permitted values, and others.

The following represent a few of the primary duties (restrictions/validations) that we may establish utilizing Data Validation −

  • Allow people to enter just numbers or text.

  • Allow integers less than, greater than, and between a specific range to be documented.

  • Allow inputs of information of a particular length Limit elements in a menu of choices to predetermined values

  • Limit date and time inputs that fall outside or inside a specific range.

  • Verify an entry according to another cell.

  • When a user chooses a cell, a message of information is displayed, alerting them of what the related cell allows.

  • Whenever the user inputs incorrect data, it shows an alert or notice of an error.

  • Find any erroneous or inaccurate entries in the verified cells.

What is a Combo Box in Excel?

A combo box in Excel is a validation of information tool that may generate a list of options for the individual. A "Form Control" is provided under the "Developer" tab's "Insert" tab. As described, it is an input box into which we may enter a distinct set of values to represent our selection. While the VBA combo box is created in a user interface where we enter our values into a list in Excel, its purpose is identical.

Data Validation is Used to Restrict Input

Employing Excel's Data Validation function constitutes one of the easiest and most efficient methods to avoid typing in a Combo Box. To put this technique into action, take the steps that follow −

  • Choose the cell(s) for which you wish to make a rule.

  • Choose Data >Data Validation.

  • Go to the Settings tab.

  • Select List under Allow. "List - to choose information from a drop-down menu."

  • Insert the assortment of cells holding the set of choices in the Combo Box in the "Source" column.

  • If you want to show the message whenever the user picks or lingers on the chosen cell(s), click the Show input message when the cell is selected checkbox.

  • Go to the Error Alert tab to customize the error messages and pick a Style.

  • Choose OK.

Using Data Validation with a specified list, you can limit the user's choices to the accessible selections while preventing them from entering straight into the Combo Box.

By using ActiveX Controls

Using ActiveX Controls, which provide more sophisticated choices for customization than conventional form controls, is yet another method to prevent input in a Combo Box. To put this technique into action, perform these steps −

  • Go to the Developer tab. You can enable it from the Excel options if you don't see it.

  • Go to the Controls group in the developer tab and click

  • From the list of ActiveX Controls, choose Combo Box.

  • Right on the combo box and click Properties

  • Find a locked property and change it to true

  • Set the "MatchEntry" property to "2 - fmMatchEntryNone" to disable typing.

  • Populate the Combo Box with the desired list of options by entering them in the "ListFillRange" property.

  • You can now close the properties window.

Prevent or disable typing in a combo box by using VBA code

Using a VBA code is also an effective way to prevent typing in the Combo box in Excel

  • Turn on the Design mode in the Developer tab. You can enable it from the Excel options if you don't see it.

  • Right-click the combo box you desire to prevent typing a menu will appear

  • Then click View Code

  • Microsoft Visual Basic for Applications window will pop off

  • Replace the original VBA code in the Code window with the below VBA code.

VBA code − Prevent typing in a Combo Box in Excel

Private Sub ComboBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
KeyAscii = 0
End Sub
  • Now hit Alt+Q, which will close the Microsoft Visual Basic for Applications window

  • Now turn off the Design mode In the Developer tab

Now you need to protect the worksheet

Consider safeguarding the worksheet to guarantee the efficiency of the strategies, as mentioned earlier. You are preventing visitors from changing the Combo Box attributes or messing with the information's validation criteria by doing so. To safeguard your worksheet −

  • Go to the Review tab.

  • To open the Protect Sheet dialog box, click on Protect Sheet.

  • You can leave it black.

    OR

    Set a password

  • You can choose the options you want users to access, like formatting cells or inserting rows.

  • Ensure that these options are deselected

    • Select locked cells

    • Select unlocked cells

By safeguarding the workbook, you can keep the Combo Box and its related constraints intact and usable.

Conclusion

In many situations, preventing or disabling typing in an Excel Combo Box is critical to ensure proper information entry and accuracy. You may efficiently restrict input to specified alternatives by using techniques like Data Validation and ActiveX Controls, avoiding the likelihood of mistakes caused by human typing. Safeguarding the workbook also improves the safety and authenticity of the Combo Box arrangement. You can safely control and optimize your Combo Box in Excel for a more seamless and controllable user interface by adhering to the step-by-step procedures given in this article.

Updated on: 10-Oct-2023

324 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements