Validation lists in excel

Use data validation to restrict the type of data or the values that users enter into a cell, like a dropdown list.

Your browser does not support video. Install Microsoft Silverlight, Adobe Flash Player, or Internet Explorer 9.

Try it!

  1. Select the cell(s) you want to create a rule for.

  2. Select Data >Data Validation.

           Data Validation

  3. On the Settings tab, under Allow, select an option:

    • Whole Number — to restrict the cell to accept only whole numbers.

    • Decimal — to restrict the cell to accept only decimal numbers.

    • List — to pick data from the drop-down list.

    • Date — to restrict the cell to accept only date.

    • Time — to restrict the cell to accept only time.

    • Text Length — to restrict the length of the text.

    • Custom – for custom formula.

  4.  Under Data, select a condition.

  5. Set the other required values based on what you chose for Allow and Data.

  6. Select the Input Message tab and customize a message users will see when entering data.

  7. Select the Show input message when cell is selected checkbox to display the message when the user selects or hovers over the selected cell(s).

  8. Select the Error Alert tab to customize the error message and to choose a Style.

  9. Select OK.

    Now, if the user tries to enter a value that is not valid, an Error Alert appears with your customized message.

Download our examples

Download an example workbook with all data validation examples in this article

If you’re creating a sheet that requires users to enter data, you might want to restrict entry to a certain range of dates or numbers, or make sure that only positive whole numbers are entered. Excel can restrict data entry to certain cells by using data validation, prompt users to enter valid data when a cell is selected, and display an error message when a user enters invalid data.

Restrict data entry

  1. Select the cells where you want to restrict data entry.

  2. On the Data tab, click Data Validation > Data Validation.

    Note: If the validation command is unavailable, the sheet might be protected or the workbook might be shared. You cannot change data validation settings if your workbook is shared or your sheet is protected. For more information about workbook protection, see Protect a workbook.

  3. In the Allow box, select the type of data you want to allow, and fill in the limiting criteria and values.

    Note: The boxes where you enter limiting values will be labeled based on the data and limiting criteria that you have chosen. For example, if you choose Date as your data type, you will be able to enter limiting values in minimum and maximum value boxes labeled Start Date and End Date.

Prompt users for valid entries

When users click in a cell that has data entry requirements, you can display a message that explains what data is valid.

  1. Select the cells where you want to prompt users for valid data entries.

  2. On the Data tab, click Data Validation > Data Validation.

    Note: If the validation command is unavailable, the sheet might be protected or the workbook might be shared. You cannot change data validation settings if your workbook is shared or your sheet is protected. For more information about workbook protection, see Protect a workbook.

  3. On the Input Message tab, select the Show input message when cell is selected check box.

  4. In the Title box, type a title for your message.

  5. In the Input message box, type the message that you want to display.

Display an error message when invalid data is entered

If you have data restrictions in place and a user enters invalid data into a cell, you can display a message that explains the error.

  1. Select the cells where you want to display your error message.

  2. On the Data tab, click Data Validation > Data Validation.

    Note: If the validation command is unavailable, the sheet might be protected or the workbook might be shared. You cannot change data validation settings if your workbook is shared or your sheet is protected. For more information about workbook protection, see Protect a workbook.

  3. On the Error Alert tab, in the Title box, type a title for your message.

  4. In the Error message box, type the message that you want to display if invalid data is entered.

  5. Do one of the following:

    To

    On the
    Style
    pop-up menu, select

    Require users to fix the error before proceeding

    Stop

    Warn users that data is invalid, and require them to select Yes or No to indicate if they want to continue

    Warning

    Warn users that data is invalid, but allow them to proceed after dismissing the warning message

    Important

Add data validation to a cell or a range

Note: The first two steps in this section are for adding any type of data validation. Steps 3-7 are specifically for creating a drop-down list. 

  1. Select one or more cells to validate.

  2. On the Data tab, in the Data Tools group, click Data Validation.

  3. On the Settings tab, in the Allow box, select List.

  4. In the Source box, type your list values, separated by commas. For example, type Low,Average,High.

  5. Make sure that the In-cell dropdown check box is selected. Otherwise, you won’t be able to see the drop-down arrow next to the cell.

  6. To specify how you want to handle blank (null) values, select or clear the Ignore blank check box.

  7. Test the data validation to make sure that it is working correctly. Try entering both valid and invalid data in the cells to make sure that your settings are working as you intended and your messages are appearing when you expect.

Notes: 

  • After you create your drop-down list, make sure it works the way you want. For example, you might want to check to see if the cell is wide enough to show all your entries.

  • Remove data validation — Select the cell or cells that contain the validation you want to delete, then go to Data > Data Validation and in the data validation dialog press the Clear All button, then click OK.

The following table lists other types of data validation and shows you ways to add it to your worksheets.

To do this:

Follow these steps:

Restrict data entry to whole numbers within limits.

  1. Follow steps 1-2 above.

  2. From the Allow list, select Whole number.

  3. In the Data box, select the type of restriction that you want. For example, to set upper and lower limits, select between.

  4. Enter the minimum, maximum, or specific value to allow.

    You can also enter a formula that returns a number value.

    For example, say you’re validating data in cell F1. To set a minimum limit of deductions to two times the number of children in that cell, select greater than or equal to in the Data box and enter the formula, =2*F1, in the Minimum box.

Restrict data entry to a decimal number within limits.

  1. Follow steps 1-2 above.

  2. In the Allow box, select Decimal.

  3. In the Data box, select the type of restriction that you want. For example, to set upper and lower limits, select between.

  4. Enter the minimum, maximum, or specific value to allow.

    You can also enter a formula that returns a number value. For example, to set a maximum limit for commissions and bonuses of 6% of a salesperson’s salary in cell E1, select less than or equal to in the Data box and enter the formula, =E1*6%, in the Maximum box.

    Note: To let a user enter percentages, for example 20%, select Decimal in the Allow box, select the type of restriction that you want in the Data box, enter the minimum, maximum, or specific value as a decimal, for example .2, and then display the data validation cell as a percentage by selecting the cell and clicking Percent Style Button image in the Number group on the Home tab.

Restrict data entry to a date within range of dates.

  1. Follow steps 1-2 above.

  2. In the Allow box, select Date.

  3. In the Data box, select the type of restriction that you want. For example, to allow dates after a certain day, select greater than.

  4. Enter the start, end, or specific date to allow.

    You can also enter a formula that returns a date. For example, to set a time frame between today’s date and 3 days from today’s date, select between in the Data box, enter =TODAY() in the Start date box, and enter =TODAY()+3 in the End date box.

Restrict data entry to a time within a time frame.

  1. Follow steps 1-2 above.

  2. In the Allow box, select Time.

  3. In the Data box, select the type of restriction that you want. For example, to allow times before a certain time of day, select less than.

  4. Enter the start, end, or specific time to allow. If you want to enter specific times, use the hh:mm time format.

    For example, say you have cell E2 set up with a start time (8:00 AM), and cell F2 with an end time (5:00 PM), and you want to limit meeting times between those times then select between in the Data box, enter =E2 in the Start time box, and then enter =F2 in the End time box.

Restrict data entry to text of a specified length.

  1. Follow steps 1-2 above.

  2. In the Allow box, select Text Length.

  3. In the Data box, select the type of restriction that you want. For example, to allow up to a certain number of characters, select less than or equal to.

  4. In this case we want to limit entry to 25 characters, so select less than or equal to in the Data box and enter 25 in the Maximum box.

Calculate what is allowed based on the content of another cell.

  1. Follow steps 1-2 above.

  2. In the Allow box, select the type of data that you want.

  3. In the Data box, select the type of restriction that you want.

  4. In the box or boxes below the Data box, click the cell that you want to use to specify what is allowed.

    For example, to allow entries for an account only if the result won’t go over the budget in cell E1, select Allow >Whole number, Data, less than or equal to, and Maximum >= =E1.

Notes: 

  • The following examples use the Custom option where you write formulas to set your conditions. You don’t need to worry about whatever the Data box shows, as that’s disabled with the Custom option.

  • The screen shots in this article were taken in Excel 2016; but the functionality is the same in Excel for the web.

To make sure that

Enter this formula

The cell that contains a product ID (C2) always begins with the standard prefix of «ID-» and is at least 10 (greater than 9) characters long.

=AND(LEFT(C2,3)=»ID-«,LEN(C2)>9)

Example 6: Formulas in data validation

The cell that contains a product name (D2) only contains text.

=ISTEXT(D2)

Example 2: Formulas in data validation

The cell that contains someone’s birthday (B6) has to be greater than the number of years set in cell B4.

=IF(B6<=(TODAY()-(365*B4)),TRUE,FALSE)

Data validation example to restrict an entry to a minimum age

All the data in the cell range A2:A10 contains unique values.

=COUNTIF($A$2:$A$10,A2)=1

Example 4: Formulas in data validation

Note: You must enter the data validation formula for cell A2 first, then copy A2 to A3:A10 so that the second argument to the COUNTIF will match the current cell. That is the A2)=1 portion will change to A3)=1, A4)=1 and so on.

For more information

Ensure that an e-mail address entry in cell B4 contains the @ symbol.

=ISNUMBER(FIND(«@»,B4))

Data validation example ensuring an e-mail address contains the @ symbol

Tip: If you’re a small business owner looking for more information on how to get Microsoft 365 set up, visit Small business help & learning.

Want more?

Connect with an expert. Learn from live instructors.

Create a drop-down list

Add or remove items from a drop-down list

More on data validation

Bottom line: Learn a fast and easy way to search any data validation list or in-cell drop-down list with the new Excel feature or free tool.

Skill level: Beginner

how-to-search-data-validation-lists-in-excel-cover-640x360

New Feature to Search Dropdown Lists

In January of 2022, Microsoft released an update that lets you search dropdown (data validation) lists in the desktop version of Excel.

It’s important to note that the feature is currently on the Insiders Beta channel for Microsoft 365. It is also flighted, which means not all users on the Beta Channel will have it immediately. Once the feature is fully flighted, it eventually moves to the Monthly and other channels.

It’s a feature I’ve been waiting on for a long time, and I’m happy it’s here!

I originally wrote this post when the feature wasn’t available, and it contains info on an add-in I developed called List Search, that allows you to search drop down lists in cells.

If you are NOT on the latest version of Excel for Microsoft 365, then the add-in will still be a great solution for you. It also contains some features that are not available yet in the native search feature in Excel.

Video Tutorial

Watch on YouTube & Subscribe to our Channel

With the new update, you can now type your search directly in the cell that contains the dropdown list. A list of results will appear that match your search term.

New Excel Feature - Search Dropdown Lists

You can select a result with your mouse or use the arrow keys and press Enter.

The search currently performs a “contains” type search for whole words. This means the item you are searching for does NOT need to start with the search term.

In the example below I am searching for apple. You can see that the results include phrases like Fuji Apple and Granny Smith Apple, which contain the search term but don’t start with it.

A Few Bugs

As awesome as this new feature is, there are a few things I’d like to be improved.

Enter Key Behavior

The first is the enter key behavior. After you find an item and hit Enter to input it the cell, the same cell remains selected. You must press Enter again to go to the next cell.

Now, this is NOT technically a bug. The same behavior exists if you use Alt+Down Arrow to open the list and find an item with the arrow keys.

However, I think data entry would be faster if the Enter key followed the same behavior it does when you enter data or a formula in a cell.

Partial Word Matches

Another issue, and probably a bigger one, is that the search currently doesn’t support partial word matches.

For example, my list contains the word Arrowroot. If I search “root”, no results are returned.

Partial word matching does exist in other areas of Excel like the search box in the filter dropdown menus. So hopefully it will make it’s way to data validation lists as well.

It will be very useful in a lot of scenarios, especially when your list contains part numbers, phone numbers, or account codes that all start with the same prefix and you want to search for text/number within the full value.

Availability

This new feature to search dropdown lists is currently available on the Beta Channel of Excel, which is part of the Office Insiders program. Office Insiders is free for all Microsoft 365 subscribers and you can learn more about it here.

Note that the feature is currently being flighted out, so you might not have it yet even if you are on the Beta Channel.

It will roll out to the other Microsoft 365 channels in the coming weeks/months.

The search feature is also available on the web/online version of Excel. It was released for that version in 2021 and I covered it in my previous post and video on 21 New Excel Features Released in 2021.

What If I’m Stuck on an Old Version of Excel?

Older versions of Excel will not receive this new feature. However, I created a free add-in called List Search that allows you to search dropdown lists. I originally created this add-in in 2016, and it’s since been downloaded over 30,000 times.

The add-in contains several additional features for sorting, exporting lists, Enter key behavior, partial word matching, auto open, and more. So if you need that partial word match searching, you can use List Search on any version of Excel.

no-built-in-way-to-search-data-validation-drop-down-lists-in-excel

Video Overview of List Search

Watch on YouTube & Subscribe to our Channel

Click the links below to jump down to the feature update videos.

  • November 2016 Update
  • April 2017 Update

Search Validation Lists with List Search

The List Search Add-in makes it fast and easy to search any validation list.  It also works with lists of data that do not contain data validation cells.

List Search Add-in Drop-down List Contains Data Validation List of Items

The List Search form contains a drop-down box that loads the selected cell’s validation list.  The drop-down box also functions as a search box.  You can type a search in the box and the results will be narrowed down as you type.  This is a Google-like search and the results will include any item that contains the search term.  The item does not have to start with the search term.

list-search-results-narrowed-down-as-you-type-data-validation-list

Once you have selected the item you are looking for, press Enter on the keyboard or press the Input Value button on the form to input the value in the selected cell.

enter-key-or-input-value-button-to-enter-value-in-cell-list-search

List Search works on any cell in any workbook.  There is NO special setup required.  Simply select a cell, press the List Search button, and start searching the list.

List Search Options & Features

The List Search Add-in contains some features that make it super fast to do data entry and work with your lists.  Press the Menu button in the List Search window to see the options.

list-search-add-in-options-sort-and-direction-settings

  • Select Next Cell – After pressing the Enter key or Input Value button, the cell below the active cell is selected.  This behavior can be changed in the direction drop-down menu.
    • Down – selects the cell below the active cell.
    • Right – selects the cell to the right of the active cell.
    • None – does not change the selection.
    • Close – closes the List Search window.
    • Paste – Copies the input value to the clipboard and pastes it to the active cell using the VBA SendKeys method.  The List Search Window closes.  This is the only option that retains the undo history in Excel.
  • Sort Order – The drop-down list can be sorted in ascending (A-Z), descending (Z-A), or original order by pressing the toggle buttons in the options menu.  This only sorts the list in the List Search window.  It does not sort the data validation list in the cell.
  • List Info – The Info button displays additional information about the drop-down list.  It currently displays the total number of items in the list.
  • Create List of Unique Values – A new button has been added that copies the contents of the drop-down list to the clipboard.  You can then paste the list to any range in the workbook.  This is a fast way to create a list of unique values when you use List Search on a cell that does NOT contain data validation.  You can also filter the list by typing a search, then copy the filtered list to the clipboard.

IMPORTANT Note: When inputting values to the active cell, the only way to retain the Undo History is by using the Paste option in the Select Next Cell drop-down list.  List Search uses macros to input the selected value, and macros typically clear the undo history in Excel when they modify the workbook.  The Paste option is a workaround that uses the SendKeys method to copy and paste the selected value.  This mimics what the user would do to copy/paste, and does NOT clear the Undo history in Excel.

Works on Lists Without Data Validation

List Search works on cells that do not contain data validation too.  If you select a cell that does NOT contain data validation and open List Search, the drop-down will be loaded with a list of unique items from the column of the selected cell.

list-search-works-on-cells-that-do-not-contain-validation

This is similar to pressing Alt+Down Arrow in a cell to see a list of values in that column.  However, the list does not need to be contiguous.  Even if the column contains blanks, List Search will still load all the unique values in the current data region or list.

November 2016 Update

I published an updated version of the List Search Add-in with a few new features.  Here is a video overview of the new features.

Watch on YouTube & Subscribe to our Channel
  1. Added a “Paste” option to the directions list.  This will copy the input value to the clipboard and paste it to the activecell.  The Paste options uses the SendKeys method in VBA to perform the paste.  This means the Undo history will NOT be cleared when using the Paste Option.
  2. Settings for the Options Menu and Input Direction Drop-down are now saved to the registry.  Your preferences will be saved and loaded when you open Excel and the add-in again in the future.
  3. Added enhancements for Excel Tables. When the activecell is in a Table and the cell does not contain validation, a unique list of values will be loaded and exclude the Table headers and total row.
  4. Added Copy List feature that copies the contents of the drop-down list to the clipboard. This feature is used to create a list of unique values from a column/table when the activecell does not contain validation. It also works when the list is filtered with a search term to only copy filtered results.

April 2017 Update

Based on your awesome feedback and requests, I’m excited to publish another update with new features.  I share the new features in the following video.

Here is a list of the new features in the April 2017 update.

  1. It added the Auto Open feature to automatically open the form when a cell that contains data validation is selected. You can toggle this option on/off with a toggle button in the options menu.
  2.  The add-in now works with data validation created by formulas (OFFSET & INDEX) and comma separated lists.  It should work with all types of data validation lists.
  3. Updated Escape Key behavior to close the List Search window.  If there is text in the search box, then Escape clears the search box.  If the search box is empty, then Escape closes the form.

In the video I also showed some cells with drop-down button icons next to them, even though the cell was not selected.  Check out my article on how to make the validation list drop-down buttons always visible to learn more about this technique.

Download the List Search Add-in (it’s Free!)

The List Search Add-in is free to download and use.  The VBA code is also open source so you can modify it for your needs.  This is also a great way to learn how macros and add-ins work if you are learning VBA.

List Search Add-in Free Download 640x360

Note: You will create a free account for the Excel Campus Members site to access the download and any future updates.

The download site also contains installation instructions and videos.

How Can My Co-workers Use List Search?

The List Search Add-in is installed on your computer, and only you will be able to see the XL Campus tab and use List Search.  If you want your co-workers to be able to use List Search there are two ways to go about it.

  1. Send them a link to this page to download and install List Search on their computer.  They will be able to use List Search on any Excel file they have open on their computer.
  2. Import the List Search userform to the VB Project in your Excel file.  You can add the List Search form to any of your workbooks.  This must be a macro enabled workbook.  You will also need to create or import the code module that contains the macro to open the List Search userform.  Then add a button to the worksheet or ribbon that opens the form.  There is a video on the download site that walks through this entire process.  Once you opt-in to download the add-in you will receive a free account to access the Excel Campus Members Area and the download site.

The List Search add-in is also available on our Hero Tools Add-in.

Hero-Tools-Tab-in-Excel-Ribbon

The Hero Tools Add-in is packed with over 100 features that will save you time with your everyday Excel tasks. It will help you automate processes with writing formulas, building pivot tables, filtering data, table of contents, navigating workbooks, date picker, and so much more.

Learn more about The Hero Tools Add-in

How Can We Make List Search Better?

I hope the List Search Add-in saves you some time searching data validation lists.  The ultimate goal is to make it faster to find the value we are looking for in long lists of data.  Please leave a comment below with any questions or suggestions.  Thank you! 🙂

Learn More about Dropdown Lists

Data validation lists are a great way to control the values that are input in a cell.  These drop-down lists also allow us to choose options that can drive financial models, reports, or dashboards.

  • You can find my complete tutorial for setting up data validation lists here.
  • Then you can learn how to make them dynamic here.
  • And you can find out how to make them dependent on one another here.

However, there is no built-in way to search the validation list in Excel.  It can be difficult to scroll through these lists when the drop-down contains a lot of items.  There are some really cool formula based solutions to this problem, but they require a lot of setup work for each validation list in your file.

The data validation in excel helps control the kind of input entered by a user in the worksheet. In other words, the input typed in a specific cell must comply with the criteria set for that cell. Data validation also allows providing instructions to the user about the input to be typed. The cell to which the data validation rule is applied is called a validated cell.

For example, the following data validation rules can be created in certain cells of Excel:

  1. A whole number between 1 (minimum) and 20 (maximum) is allowed.
  2. A date is allowed to be entered which is greater than September 15, 2000 (start date) or lesser than September 15, 2020 (end date).
  3. A text entry is allowed which matches any of the values (“yes,” “no,” and “cannot say”) of a drop-down list.

The pointers “a,” “b,” and “c” are the validating criteria defined for certain cells. If the input in these cells does not correspond to the respective pointer (a, b, or c), an error alert message is displayed by Excel.

Apart from setting the criteria, data validation in excel also allows to create a pre-defined range of inputs (drop-down list). In such cases, the user is asked to select the appropriate option (input) from this range. This ensures that all the data entries follow the same format.

Since the entries of all users are standardized, data validation brings about consistency and reduces errors. The “data validation” option is available in the “data tools” group of the Data tab of Excel.

Table of contents
  • What is Data Validation in Excel?
    • How to Use Data Validation in Excel?
      • Example #1–“Data Validation” Window Explained
      • Example #2–Decimal Number Validation
    • Data Formats in Data validation
    • The Different Validation Criteria
    • The Different Error Alert Styles
    • Purpose of Data Validation in Excel
    • The Limitations of Data Validation in Excel
    • Frequently Asked Questions
    • Recommended Articles

How to Use Data Validation in Excel?

Let us consider some examples to understand the working of the data validation feature of Excel.

You can download this Data Validation Excel Template here – Data Validation Excel Template

Example #1–“Data Validation” Window Explained

The following image shows a list of numbers in column B. We want to perform the following tasks:

  • Show how to create a data validation rule on the range B1:B4.
  • Explain the tabs of the “data validation” window.

The steps explaining the creation of a data validation rule in Excel are listed as follows:

  1. Select the cells on which the data validation rule has to be created. So, select the range B1:B4.

    Data Validation step 1

  2. Click the data validation drop-down (in the “data tools” group) from the Data tab of Excel. The same is shown in the following image.

    Data Validation step 2

  3. Select “data validation” from the drop-down list.

    Data Validation step 3

  4. The “data validation” window appears, as shown in the following image.

    Data Validation step 4

  5. The first tab is “settings,” which contains the validation criteria. The same is shown in the succeeding image.

    From the drop-down list under “allow,” one can select the data format allowed to the users. The drop-down list under “data” is used for defining the criteria.

    For instance, if the input should be entered as a whole number, select the same from the drop-down list under “allow.” Once “whole number” is selected, one can choose the minimum and the maximum range between which this number is allowed to be entered.

    Likewise, the desired validation criteria can be defined for the user.

    Note: Refer to the topics “The Different Data Formats” and “The Different Validation Criteria” of this article for more information on adding validation criteria.

    Data Validation step 5

  6. The checkbox “ignore blank” is selected by default. This selection tells Excel to ignore the blank values.

    Data Validation step 6

  7. The second tab is “input message,” as shown in the succeeding image. One can enter the “title” and the “input message,” which are displayed when a validated cell is selected.

    Note: An “input message” tells the user about the kind of input allowed in a validated cell. However, it is optional to add an input message. But, if one does add an input message, ensure that the checkbox of “show input message when cell is selected” is checked.

    Data Validation step 7

  8. The third tab is “error alert.” In this tab, one can enter the “title” and the “error message” that are displayed on typing invalid data in the validated cell.

    From the “style” drop-down, one can select any of the three options, “stop,” “warning” or “information.” These are shown in the succeeding image.

    Note 1: An “error message” is a customized message which tells the user that he/she has made an error while typing data in the validated cell. However, it is optional to add an error message. If an error message is added, ensure that the checkbox of “show error alert after invalid data is entered” is checked.

    Note 2: In case an error message is not added, Excel displays the default error message, which states that restrictions have been defined for the validated cell.

    Note 3: For more information on the error alert styles, refer to the topic “The Different Error Alert Styles” of this article.

    Data Validation step 8

  9. Once the entries in the three tabs, “settings,” “input message,” and “error alert” have been defined, click “Ok” in the “data validation” window.

    The data validation excel rule is applied to the selected range B1:B4. Likewise, one can create a data validation rule by selecting either a single cell or a range of cells in Excel.

    Note: For creating a data validation rule, it is mandatory to enter the validation criteria in the “settings” tab (step 5). However, it is optional to define the tabs “input message” (step 7) and “error alert” (step 8).

Example #2–Decimal Number Validation

Working on the data of example #1, we want to perform the following tasks:

  • Create a data validation excel rule on cell B1. In this cell, a decimal number greater than or equal to zero is allowed to be entered.
  • Define an input message which appears on selecting cell B1. The title should be “negative number detected” and the message should be “enter number greater than zero.”

The steps for performing the stated tasks are listed as follows:

Step 1: Select cell B1 which contains -2.5. From the Data tab of Excel, click the “data validation” drop-down. Select “data validation.”

Step 2: The “data validation” window appears, as shown in the following image. In the “settings” tab, select “decimal” under the “allow” drop-down.

Under the “data” drop-down, select “greater than or equal to.” In the box under “minimum,” enter “0” (without the double quotation marks).

Example 1-1

Step 3: In the “input message” tab, select the checkbox of “show input message when cell is selected.”

In the box under “title,” type “negative number detected” without the double quotation marks. In the box “input message,” type “enter number greater than zero.” This should also be written without the double quotation marks. Click “Ok.”

The data validation rule is created on cell B1. To cross-check it, select the validated cell B1. The defined input message appears, as shown in the following image. 

Example 1

The number -2.5 was already there in cell B1 before the creation of the validation rule. This number is not deleted (from cell B1) even after creating a data validation rule.

However, in future, if a number is entered in cell B1, it must conform to the newly created rule. This implies that a decimal number greater than or equal to zero can be entered in cell B1. So, negative numbers are restricted in this cell. In case this rule is not complied with, Excel will display the default error alert.

Data Formats in Data validation

While entering data in a validated cell, there are certain formats that are allowed to the user. The rule creator (who is creating the data validation rule) can pick any of these formats based on which a validation rule can be created.

In the “settings” tab of the “data validation” window, the “allow” drop-down shows the following formats:

  1. Any value: This implies that no validation will be executed. In case a data validation rule is created and then “any value” is selected, the created validation rule is removed. However, the input message of the created validation rule can be viewed even after “any value” has been selected.
  2. Whole number: This requires that the user should enter a whole number in the validated cell.
  3. Decimal: This implies that the data format allowed in the validated cell is decimal numbers.
  4. List: This implies that the format allowed is a drop-down list. So, a drop-down list consisting of pre-defined values needs to be created. This drop-down list can be created in any of the following ways:
    • Supply the values directly in the box under “source.”
    • Provide the reference to the range (in the “source” box), which consists of the required values.
    • Enter the name of the named range (in the “source” box), which begins with an “equal to” (=) sign.
  1. Date: This implies that the user can enter only a date in the validated cell.
  2. Time: This implies that a time value should be entered in the validated cell.
  3. Text Length: This helps fix the number of digits or text entered in a validated cell. For instance, the user can enter either numbers or text up to 5 digits or 5 characters respectively.
  4. Custom: This allows one to create a formula. This formula is used to validate (restrict) the input entered by the user. For instance, a formula can be entered to ensure that a text entry ends with certain characters, the text should be in uppercase or the entry must only be numeric, etc.

The Different Validation Criteria

Excel presents different criteria for validating data. The rule creator can select any of these criteria. Based on this selection, one can set the limits within which the input is allowed.

In the “settings” tab of the “data validation” dialog box, the drop-down under “data” shows the following validating criteria:

  1. Between: This implies that the input should be between the minimum and the maximum numbers specified.
  2. Not between: This implies that the input should not be between the minimum and the maximum numbers specified.
  3. Equal to: This implies that the input should be equal to the specified value. In other words, the input should be the same as the specified value.
  4. Not equal to: This implies that the input should not be equal to the specified value. In other words, the input should be different from the specified value.
  5. Greater than: This implies that the input should be greater than the minimum number specified.
  6. Less than: This implies that the input should be lesser than the maximum number specified.
  7. Greater than or equal to: This implies that the input should be greater than or equal to the minimum number specified.
  8. Less than or equal to: This implies that the input should be lesser than or equal to the maximum number specified.

The Different Error Alert Styles

There are different error alert styles in Excel. The rule creator can select any of these styles to notify the user that an error has been made while typing data in the validated cell.

In the “error alert” tab of the “data validation” window, the drop-down under “style” presents the following options:

  1. Stop: This stops the users from entering invalid data in the validated cell. With the “stop” style, the error alert message presents the following main options to the user:
    • Retry– Clicking “retry” allows typing a new input.
    • Cancel–Clicking “cancel” deletes the invalid input.

The “stop” style is the default error alert style of Excel.

Data Validation - Stop

  1. Warning: This warns the users that an invalid input has been entered. However, it does not stop the user from entering incorrect data. With the “warning” style, the user is presented with the following main options:
    • Yes–Clicking “yes” makes Excel accept the invalid input.
    • No–Clicking “no” allows typing a new input.
    • Cancel–Clicking “cancel” deletes the invalid input.

Warning

  1. Information: This informs the user that the input entered is invalid. Like the “warning” style, this also does not stop the user from entering incorrect data. With the “information” style, the user is presented with the following main options:
    • Ok–Clicking “Ok” makes Excel accept the invalid input.
    • Cancel–Clicking “cancel” deletes the invalid input.

Information

By selecting a style, its respective icon appears in the error alert message displayed by Excel.

For instance, with the “stop” style, the cross within the red circle is shown (in the error alert message) as the user enters invalid data. Likewise, with the “warning” and “information” styles, the exclamation mark (within a yellow triangle) and the “i” sign (within a blue circle) show up respectively.

Note: Apart from the main options listed (in the preceding pointers 1, 2, and 3), Excel also displays the “help” option in all the error alert messages, irrespective of the style selected.

Purpose of Data Validation in Excel

The objectives of data validation in excel are listed as follows:

  • To restrict the users from entering unwanted or incorrect data values in the worksheet
  • To sort and study the data obtained with the help of defined criteria
  • To suggest the valid data format to the users through customized input messages (displayed when a validated cell is selected)

Excel Data validation is particularly helpful in the following situations:

  • When the number of users is large and there is a possibility of entering inputs in different formats
  • When the allowed entries need to be defined with a drop-down list
  • When an error alert (warning message) needs to be displayed on entering invalid data

The Limitations of Data Validation in Excel

The limitations of data validation in excel are listed as follows:

  • Data validation in excel does not prevent a user from copying an incorrect input from a non-validated cell to a validated cell. It can stop one from typing an incorrect input but not from copying the same. Hence, the purpose of data validation can become pointless if a user copies and pastes an invalid input.
  • Excel Data validation cannot fully protect a worksheet from invalid data entries. If a user copies an incorrect input from a non-validated cell and pastes it in a validated cell, the validation rule in the latter cell is eliminated. As a result, the validation rule is absent on the copied data.

Frequently Asked Questions

1. Define data validation in Excel.

Data validation restricts (limits) the type of input entered by a user in the worksheet. One can set the criteria for a specific cell and ensure that the input typed (in that cell) complies with it.

For instance, in cell A1, one is allowed to type only a decimal number between 1.5 and 9.5. This is a data validation rule applied to cell A1 of the worksheet.

2. How can a data validation rule be edited in Excel?

Let us say that rule X has been applied to cells A1 and D1. We want to change this to rule Y for both the mentioned cells.

The steps to edit a data validation rule are listed as follows:

a. Select any of the cells to which rule X has been applied.
b. Select “data validation” from the “data validation” drop-down (in the “data tools” group) of the Data tab.
c. In the “settings” tab of the “data validation” window, enter the new criteria as per rule Y.
d. Select the checkbox of “apply these changes to all other cells with the same settings.” This ensures that rule Y is applied to both the cells A1 and D1.
e. Click “Ok.”

The rule Y has been applied to both cells A1 and D1.

Note: The new data validation rule can be applied to all the validated cells only if they all had the same validation criteria initially. In this case, the initial validation criterion (rule X) was the same for both the validated cells (A1 and D1).

3. How can a data validation rule be removed in Excel?

The steps to remove (delete) a data validation rule are listed as follows:

a. Select the validated cell.
b. From the “data validation” drop-down (in the “data tools” group) of the Data tab, select “data validation.”
c. The “data validation” window opens. In the “settings” tab, click “clear all” appearing at the bottom left side.
d. Click “Ok.”

The validation rule will be cleared from the selected cell (selected in step a).

Note: To remove the same validation rule applied to multiple cells, select the checkbox of “apply these changes to all other cells with the same settings.” Thereafter, click “clear all” followed by “Ok.”

Recommended Articles

This has been a guide to data validation in Excel. Here we discuss how to create a data validation rule in Excel along with examples and downloadable Excel templates. You may also look at these useful functions in Excel–

  • How to Insert a Checkbox in Excel?A checkbox in excel is a square box used for presenting options (or choices) to the user to choose from.read more
  • PERCENTILE Excel FunctionThe PERCENTILE function is responsible for returning the nth percentile from a supplied set of values. read more
  • Paste Special ShortcutsPaste special in Excel allows you to paste partial aspects of the data copied. There are several ways to paste special in Excel, including right-clicking on the target cell and selecting paste special, or using a shortcut such as CTRL+ALT+V or ALT+E+S.read more
  • Data Table – ExamplesA data table in excel is a type of what-if analysis tool that allows you to compare variables and see how they impact the result and overall data. It can be found under the data tab in the what-if analysis section.read more
Skip to content

Data Validation in Excel – Adding Drop-Down Lists in Excel

Home » Excel » Data Validation in Excel – Adding Drop-Down Lists in Excel

We can control the type of data or the values that users can enter into a particular cell or range using Data Validation in Excel.

In This Section:

  • » What is data validation and Its Use:
  • » Creating a simple list to enter gender of a person – Practical Learning
  • » How to choose list items from a Worksheet
  • » How to Set user instructions message
  • » How to Set user alert message
  • » Example File

What is data validation and Its Use:

Data Validation is a feature available in Excel to define restrictions and what data can enter in a cell or a range.
For example,
1. We can restrict data entry to a certain range of values
2. User can select a choice form predefined list
3. We can display a message to provide the instruction to the user
4. We can display a message when user enter an incorrect value

Creating a simple list to enter gender of a person – Practical Learning

Step 1: Select a Range or Cells which you want to restrict or add data validation

data validation-1

Step 2: Click on the Data Validation tool from the Data Tab

data validation-2

Step 3: Set the Validation Criteria: Select List from the Allow drop-down list in the Setting Tabs

data validation-3

Step 5: Enter the values to show in the Drop-down list

data validation-4

You are done! Now you can check the range, your list is available to choose

data validation-5

How to choose list items from a Worksheet

It is a good practice to have your list of values in the worksheet and choose those values for drop-down list. It is particularly very useful when your data list is having more number of items or your list is changing frequently.

Follow the below Steps to choose the list items from worksheet:

  1. Select the Range / Cells to restrict or add data validation.
  2. Click Data Validation Tool from Data menu
  3. Click List in the Allow drop-down list from the Settings tab
  4. Click Source button to select the list Items
  5. Select the Range to fill the drop-down

data validation-6

How to set user instructions message

You can provide the instructions to the user while entering the data. In the following example, we will see how to restrict the enter values between a range and provide the user instructions.

Follow the below Steps to choose the list items from worksheet:

  1. Select the Range / Cells to restrict or add data validation.
  2. Click Data Validation Tool from Data menu
  3. Select Whole number from the Allow drop-down list in the Settings tab
  4. Select between number from the Data drop-down list in the Settings tab
  5. Enter Minimum and Maximum Values (example: 1 and 100)
  6. data validation-7

  7. Goto Input Message Tab and Enter Required Title and Instructions in the Input Message Box (example: ‘Note:’ and ‘Please enter any value between 1 and 100’), then Click on OK
  8. data validation-8

  9. You are done! Now you can select the cell, you can see the instructions
  10. data validation-9

How to Set user alert message

You can provide the error message to the user while entering the incorrect data. In the following example, we will see how to provide an alert message to the user.

Follow the below Steps to choose the list items from worksheet:

    The below first 5 steps are same as above

  1. Select the Range / Cells to restrict or add data validation.
  2. Click Data Validation Tool from Data menu
  3. Select Whole number from the Allow drop-down list in the Settings tab
  4. Select between number from the Data drop-down list in the Settings tab
  5. Enter Minimum and Maximum Values (example: 1 and 100)
  6. Goto Error Alert Tab and Enter Required Title and Instructions in the Error Message Box (example: ‘Note:’ and ‘You can only enter the values between 1 and 100’)
  7. data validation-10

  8. You are done! Now you can select the cell, and try to enter a value which is not between 1 and 100
  9. data validation-11

Example File

Download this example file and see different ways of using data validation features of Excel.

ANALYSIS TABS – Data Validation

Effortlessly Manage Your Projects and Resources
120+ Professional Project Management Templates!

A Powerful & Multi-purpose Templates for project management. Now seamlessly manage your projects, tasks, meetings, presentations, teams, customers, stakeholders and time. This page describes all the amazing new features and options that come with our premium templates.

Save Up to 85% LIMITED TIME OFFER
Excel VBA Project Management Templates
All-in-One Pack
120+ Project Management Templates
Essential Pack
50+ Project Management Templates

Excel Pack
50+ Excel PM Templates

PowerPoint Pack
50+ Excel PM Templates

MS Word Pack
25+ Word PM Templates

Ultimate Project Management Template

Ultimate Resource Management Template

Project Portfolio Management Templates

Related Posts

    • What is data validation and Its Use:
    • Creating a simple list to enter gender of a person – Practical Learning
    • How to choose list items from a Worksheet
    • How to set user instructions message
    • How to Set user alert message
    • Example File

VBA Reference

Effortlessly
Manage Your Projects

120+ Project Management Templates

Seamlessly manage your projects with our powerful & multi-purpose templates for project management.

120+ PM Templates Includes:

Effectively Manage Your
Projects and  Resources

With Our Professional and Premium Project Management Templates!

ANALYSISTABS.COM provides free and premium project management tools, templates and dashboards for effectively managing the projects and analyzing the data.

We’re a crew of professionals expertise in Excel VBA, Business Analysis, Project Management. We’re Sharing our map to Project success with innovative tools, templates, tutorials and tips.

Project Management
Excel VBA

Download Free Excel 2007, 2010, 2013 Add-in for Creating Innovative Dashboards, Tools for Data Mining, Analysis, Visualization. Learn VBA for MS Excel, Word, PowerPoint, Access, Outlook to develop applications for retail, insurance, banking, finance, telecom, healthcare domains.

Analysistabs Logo

Page load link

VBA Projects With Source Code

3 Realtime VBA Projects
with Source Code!

Take Your Projects To The Next Level By Exploring Our Professional Projects

Go to Top

Today we are learning how to make dynamic multi columnar data validation lists in Excel that helps display much more data in the drop down list and are far superior and flexible than usual data validated lists. Here is what we will achieve by the end of this tutorial (left) and what we usually get with usual data validation lists (right)

A simple data validation list helps us display specific data range in the form of drop-down list in a desired cell.

A while back we learnt how to make dynamic data validation lists based on Excel tables that grow as the base data grow. It is much easier approach to data validation lists without the hassles of using OFFSET function coupled with unnecessary bits with more limitations still. And I implemented the same idea in designing Invoice template. However, it had single column data list and today we will be updating the same template with multi-column data validation list.

And this will be our final result once again:

Multi Column Data validation List – Step by step

Step 1: Download the excel workbook that if you intend to work along and open it in Excel.

In this workbook we already have the dummy data for customers and products. And few other techniques applied for invoice to work flawlessly. For the purpose of this tutorial I have simply removed the simple data validation list that we will update with a better solution.

To learn how this template was originally made and different techniques applied check this tutorial: FREE Excel Invoice Template V1.0 with Customer and Product list – Unlocked + Download ready!

Step 2: Go to customers worksheet and name the cell B1 CustomerName by typing it in the name box and pressing enter.

Step 3: Have an active cell inside the table in Customers worksheet and go to design tab > change the name to CustomersTable.

Step 4: Go to Formulas tab > in defined names group click Name manager > click Define Name. A new dialogue box will appear. Make the changes as following:

  1. Name: CusTab
  2. Refers to: =CustomersTable (same name that we gave to table in Step 3 above)

Step 5: Go to formula tab again > click define name and make the following input:

Name: CusTabFix
Refers to: =CusTab

What in the Name you are doing!

Now you must be confused that why we have defined the name twice for a table that already gets a name by default.

For some weird reasons the combo box that we will use to make multi-column data validation list does not take named ranges based on table names even if it refers to a table. That is why I wrapped a table name inside a named range and then wrap it again under another name to work around this problem.

Step 6: If you don’t already have the developer tab enabled then follow the steps as shown following:

Step 4: Go to developer tab > In controls group click Insert drop down button > click combo box under active X control. Cursor will change to let you draw the combo box. Point to the cell where you want it and draw it by clicking and holding left mouse button and releasing it once done:

Step 5: Right click on inserted combo box and click properties. A long dialogue box will open with lots of properties.

Step 6: Few of the important changes that I made in properties:

  1. Name: CustomersList
  2. Border color: Menu bar or Orange
  3. Border style: 0
  4. ColumnCount: 4
  5. ColumnWidths: 100 pt;80 pt;80 pt;100 pt [defines how wide each column should be in the list]
  6. Drop button style: 2
  7. Linked cell: CustomerName
  8. ListFillRange: CusTabFix
  9. ListWidth: 390 pt

This is how properties look after the changes:

And this is how it performed after the changes:

Step 7: Now that we have the list working, we can fetch the contact details of customers in the box under combo box using a formula in cell H10 of Invoice worksheet:

=IFERROR(VLOOKUP(CustomerName,CustomersTable,5,FALSE),””)

Remember CustomerName is the name we gave to cell above customer table. This cell is also used as linked cell in combo box properties and it is where we get the output of combo box. And it changes if we select a different name from the list.

Awesome!

Hope you have a good use of this technique in your work as it adds much more understanding to the user while making selections from the list.

See all How-To Articles

Data Validation is a tool in Excel that lets you restrict which entries are valid in a cell. Here are 10 rules and techniques to help you make the most out of Data Validation and its many features.

  1. Use Drop-Down Lists
  2. Data Validation Based on Another Cell
  3. ToolTips and Error Messages
  4. Options and Settings
  5. Date and Time Formats
  6. Set a Character Limit
  7. Validate Phone Numbers and Emails
  8. Custom Formulas
  9. Change or Remove Data Validation Rules
  10. Issues and Fixes

limit restrict cell values 3

Use Drop-Down Lists

The most useful type of data validation is the drop-down list feature. For instructions on creating a drop-down list, see Create or Add a Drop-Down List in Excel and Google Sheets.

DDList intro

There are plenty of uses for drop-down lists and many ways to create them. For example, a simple yes/no drop-down list like the one below can be added as a quick and dependable indicator in a spreadsheet.

YesNo Intro

You can also use VBA to create a drop-down list in a cell. Enter this code in the VBA editor:

Sub DropDownListinVBA()
Range("A2").Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Formula1:="Orange,Apple,Mango,Pear,Peach"
End Sub

Dynamic Drop-Down Lists

  • When you create a drop-down list based on a range of cells using a data validation rule, if the data in that specific range changes, then the values in the drop-down list also change.

dynamicdropdown intro

  • Go a step further with a cascading drop-down list based on the value that is selected in a different list. In the example below, the user has selected LG as the Phone Make. The list of Phone Models then shows only the LG models. If the user were to select either Apple or Samsung, then the list would change to show the relevant models for those makes of phone.

CascadingIntro

  • An alternative method is to use an IF statement within the data validation feature to show a specific list that changes according to what the user selects. In the example below, if the user selects Show Fruit, then the fruit drop-down list is shown, whereas selecting Show Meat brings up the meat drop-down list.

drop down list if statement Main

Filter Data With a Drop-Down List

You can use Excel’s filter tool alongside a drop-down list for extended functionality.

  • Filters and drop-down lists are similar and even use the same keyboard shortcut (CTRL + SHIFT + L). In a data validation context, the shortcut activates a drop-down menu.

Toggle Autofilter

  • A drop-down list can also be used as a filter in Excel. It enables you to extract rows of data that match the entry in the drop-down list and return these rows to a separate area of the worksheet.

filter intro

Drop-Down List Formatting and Display Tools

  • If you want to create a drop-down list where the background color depends on the text selected, you can use Conditional Formatting to amend the background color when an item from the list is selected.

DropDown Intro

  • When you create a drop-down list, the default value of the cell where you have placed the list is usually blank. It can be useful to pre-populate this cell with either a default value or a message to the user, such as Select…

DD Default SelectList

  • Once you’ve created a drop-down list, you can use the SORT and UNIQUE Functions to sort the drop-down list into alphabetical order.

DropDownSort Intro

  • To make a drop-down list more readable, you can group a list of items by category (phone models in brand groups, for example).

drop down subcategories final data

AutoComplete Drop Down

AutoComplete is a useful feature of Excel in that it can reduce the number of characters you need to type in each cell. The standard data validation drop-down functionality does not support AutoComplete. However, you can learn here how to approximate autocomplete with a drop-down list. Then, when you start typing the first letters of an entry in the drop-down list, the rest of the entry automatically shows up.

AutoComplete intro

Drop Down Populates Another Cell

  • Selecting an item from a drop down can populate a different cell in Excel and Google Sheets. For example, in the graphic below, Patel is selected from the list, and the cell below is then populated with the value 34. You can learn how to do this by clicking here.

DropDownPopulates intro

  • Using a drop-down list, you can also insert a picture into another cell automatically.

ChangePicture Int

Data Validation Based on Another Cell

When entering values in Excel, you can restrict the data that is entered into any range of cells based on text or a value held in another cell.

DataValidation Example

  • When you create a drop-down list, you can write a custom input message that is seen on the screen when a cell is selected. This input message can also be referred to as a ToolTip.

input message data validation 4a

  • You can also customize the output (error alert) message that is returned to the user if invalid data is entered into a cell.

enable error alert data validation final

Options and Settings

  • There are seven different data types you can select from the Allow box of the Validation criteria: Whole number, Decimal, List, Date, Time, Text length, and Custom.
  • The Ignore blank option is only available if you are actually editing a cell that has that option switched off.

ignoreblanks checked

  • You can also choose, when editing a data validation rule, whether or not to apply the changes to other cells with the same settings.

Date and Time Formats

You can use Data Validation to restrict the format entered into a cell to ensure it is a date, and also to restrict the entry to be set between a start date and an end date.

DatavalidationDates intro

Set a Character Limit

In Excel, the number of characters allowed in a single cell is 32767. However, you can set your own character limit for a text cell.

set a character limit data validation final

Validate Phone Numbers and Emails

  • You can use Data Validation to ensure that a phone number is entered correctly into Excel.

validate phone numbers final data

  • You can also use Data Validation to ensure that an email address contains a @ sign and does not have any spaces or commas in it.

EmailDataValid Intro

Custom Formulas

You can write a custom formula to make your own data validation rules. In the example below, the formula ensures that the data in a cell begins with certain text.

data validation must begin with

Custom Formula Examples

  • You can use the INDIRECT Function in Excel in conjunction with a data validation drop-down list to create a cell reference from text.

INDIRECT Main Function

  • Use the ISNUMBER Function to check that the data inputted is in fact, a number. Data Validation has a built-in Whole number option, but you can generalize further with a custom formula.

data validation numbers

  • Use a the ISTEXT Function to check for text. The example below allows only text values in the cells with data validation applied.

Validate Data Validation

  • You can use a data validation drop down with the COUNTIF Function to count cells that meet certain criteria and return a total.

mega article drop down

  • COUNTIF is also useful for preventing users from entering duplicate values.

prevent duplicate entries data validation final

  • A risk score matrix is a matrix that is used during risk assessment in order to calculate a risk value by inputting the likelihood and consequence of an event. You can use a data validation drop down in conjunction with the VLOOKUP and MATCH Functions to create a risk score matrix.

Change or Remove Data Validation Rules

  • If you have a data validation rule set in Excel, you can find any restricted values by selecting Data validation in the Go To Special dialog box.

restricted values data validation

  • You can copy data validation rules from one set of cells to another set of cells by using the Paste Special command (CTRL + ALT + V).

DataValidationCopy intro

  • If you already have rules set up in a worksheet, you can amend the validation rules should your requirements change.

change data validation

  • You can amend the contents of a drop-down list by following the instructions in this tutorial.

dropdown intro

  • You can easily update (change, extend, or have fewer items) a drop-down list by adding or deleting items from the list’s source range.

update drop down list 1

  • If data validation on a range is no longer required, you can remove it.

datavalidation remove cleared

  • If you no longer require a drop-down list, you can easily remove the data validation settings by following the instructions in this tutorial.

RemoveValidation Intro

Issues and Fixes

  • If you have a value in Google Sheets that does not match the items in your drop-down list (an invalid item), you get a red triangle in the top left corner of the cell. To get rid of this triangle, you can follow the steps in this tutorial.

red triangle visible

  • There are a number of reasons why your data validation rule or drop-down list is not working correctly. You can troubleshoot these issues by referring to this tutorial.

data-validation error drop down

  • A mismatch error can occur when you run VBA code. The error stops your code from running completely and flags the error by means of a message box. One of the ways you can prevent this from happening is to use Data Validation on the spreadsheet to prevent the user from causing worksheet errors in the first place. Only allow them to enter values that don’t cause worksheet errors.

PIC 01

Introduction

Data validation is a feature in Excel used to control what a user can enter into a cell. For example, you could use data validation to make sure a value is a number between 1 and 6, make sure a date occurs in the next 30 days, or make sure a text entry is less than 25 characters.

Data validation can simply display a message to a user telling them what is allowed as shown below:

Example data validation message displayed when cell selected

Data validation can also stop invalid user input. For example, if a product code fails validation, you can display a message like this:

data validation error alert invalid product code example

In addition, data validation can be used to present the user with a predefined choice in a dropdown menu:

Example data validation dropdown menu

This can be a convenient way to give a user exactly the values that meet requirements.

Data validation controls

Data validation is implemented via rules defined in Excel’s user interface on the Data tab of the ribbon.

Data validation controls on the data tab of the ribbon

Important limitation

It is important to understand that data validation can be easily defeated. If a user copies data from a cell without validation to a cell with data validation, the validation is destroyed (or replaced). Data validation is a good way to let users know what is allowed or expected, but it is not a foolproof way to guarantee input.

Defining data validation rules

Data validation is defined in a window with 3 tabs: Settings, Input Message, and Error Alert:

Data validation window has three main tabs

The settings tab is where you enter validation criteria. There are a number of built-in validation rules with various options, or you can select Custom, and use your own formula to validate input as seen below:

Data validation settings tab example

The Input Message tab defines a message to display when a cell with validation rules is selected. This Input Message is completely optional. If no input message is set, no message appears when a user selects a cell with data validation applied. The input message has no effect on what the user can enter — it simply displays a message to let the user know what is allowed or expected. 

Data validation settings tab

The Error Alert Tab controls how validation is enforced. For example, when style is set to «Stop», invalid data triggers a window with a message, and the input is not allowed. 

Data validation error alert tab

The user sees a message like this:

Example data validation error alert message

When style is set to Information or Warning, a different icon is displayed with a custom message, but the user can ignore the message and enter values that don’t pass validation. The table below summarizes behavior for each error alert option.

Alert Style Behavior
Stop Stops users from entering invalid data in a cell. Users can retry, but must enter a value that passes data validation. The Stop alert window has two options: Retry and Cancel.
Warning Warns users that data is invalid. The warning does nothing to stop invalid data. The Warning alert window has three options: Yes (to accept invalid data), No (to edit invalid data) and Cancel (to remove the invalid data).
Information Informs users that data is invalid. This message does nothing to stop invalid data. The Information alert window has 2 options: OK to accept invalid data, and Cancel to remove it.

Data validation options

When a data validation rule is created, there are eight options available to validate user input:

Any Value — no validation is performed. Note: if data validation was previously applied with a set Input Message, the message will still display when the cell is selected, even when Any Value is selected.

Whole Number — only whole numbers are allowed. Once the whole number option is selected, other options become available to further limit input. For example, you can require a whole number between 1 and 10.

Decimal — works like the whole number option, but allows decimal values. For example, with the Decimal option configured to allow values between 0 and 3, values like .5, 2.5, and 3.1 are all allowed.

List — only values from a predefined list are allowed. The values are presented to the user as a dropdown menu control. Allowed values can be hardcoded directly into the Settings tab, or specified as a range on the worksheet.

Date — only dates are allowed. For example, you can require a date between January 1, 2018 and December 31 2021, or a date after June 1, 2018.

Time — only times are allowed. For example, you can require a time between 9:00 AM and 5:00 PM, or only allow times after 12:00 PM.

Text length — validates input based on number of characters or  digits. For example, you could require code that contains 5 digits.

Custom — validates user input using a custom formula. In other words, you can write your own formula to validate input. Custom formulas greatly extend the options for data validation. For example, you could use a formula to ensure a value is uppercase, a value contains «xyz», or a date is a weekday in the next 45 days.

The settings tab also includes two checkboxes:

Ignore blank — tells Excel to not validate cells that contain no value. In practice, this setting seems to affect only the command «circle invalid data». When enabled, blank cells are not circled even if they fail validation.

Apply these changes to other cells with the same settings — this setting will update validation applied to other cells when it matches the (original) validation of the cell(s) being edited.

Note: You can also manually select all cells with data validation applied using Go To + Special, as explained below.

Simple drop down menu

You can provide a dropdown menu of options by hardcoding values into the settings box, or selecting a range on the worksheet. For example, to restrict entries to the actions «BUY», «HOLD», or «SELL» you can enter these values separated with commas as seen below:

Data validation dropdown menu with hardcoded values

When applied to a cell in the worksheet, the dropdown menu works like this:

Data validation dropdown menu hardcoded values in use

Another way to supply values to a dropdown menu is to use a worksheet reference. For example, with sizes (i.e. small, medium, etc.) in the range F3:F6, you can supply this range directly inside the data validation settings window:

Data validation dropdown menu values with worksheet reference

Note the range is entered as an absolute address to prevent it from changing as the data validation is applied to other cells.

Tip: Click the small arrow icon at the far right of the source field to make a selection directly on the worksheet so you don’t have to enter the range manually.

You can also use named ranges to specify values. For example, with the named range called «sizes» for F3:F7, you can enter the name directly in the window, starting with an equal sign:

Data validation dropdown menu values with named range

Named ranges are automatically absolute, so they won’t change as the data validation is applied to different cells. If named ranges are new to you, this page has a good overview and a number of related tips.

Tip — if you use an Excel Table for dropdown values, Excel will expand or contract the table automatically when dropdown values are added or removed. In other words, Excel will automatically keep the dropdown in sync with values in the table as values are changed, added, or removed. If you’re new to Excel Tables, you can see a demo in this video on Table shortcuts.

Data validation with a custom formula

Data validation formulas must be logical formulas that return TRUE when input is valid and FALSE when input is invalid. For example, to allow any number as input in cell A1, you could use the ISNUMBER function in a formula like this:

=ISNUMBER(A1)

If a user enters a value like 10 in A1, ISNUMBER returns TRUE and data validation succeeds. If they enter a value like «apple» in A1, ISNUMBER returns FALSE and data validation fails.

To enable data validation with a formula, selected «Custom» in the settings tab, then enter a formula in the formula bar beginning with an equal sign (=) as usual.

Troubleshooting formulas

Excel ignores data validation formulas that return errors. If a formula isn’t working, and you can’t figure out why, set up dummy formulas to make sure the formula is performing as you expect. Dummy formulas are simply data validation formulas entered directly on the worksheet so that you can see what they return easily. The screen below shows an example:

Testing data validation with dummy formulas

Once you get the dummy formula working like you want, simply copy and paste it into the data validation formula area.

If this dummy formula idea is confusing to you, watch this video, which shows how to use dummy formulas to perfect conditional formatting formulas. The concept is exactly the same.

Data validation formula examples

The possibilities for data validation custom formulas are virtually unlimited. Here are a few examples to give you some inspiration:

To allow only 5 character values that begin with «z» you could use:

=AND(LEFT(A1)="z",LEN(A1)=5)

This formula returns TRUE only when a code is 5 digits long and starts with «z». The two circled values return FALSE with this formula. 

To allow only a date within 30 days of today:

=AND(A1>TODAY(),A1<=(TODAY()+30))

To allow only unique values:

=COUNTIF(range,A1)<2

To allow only an email address

=ISNUMBER(FIND("@",A1)

Data validation to circle invalid entries

Once data validation is applied, you can ask Excel to circle previously entered invalid values. On the Data tab of the ribbon, click Data Validation and select «Circle Invalid Data»:

Circle invalid values with data validation - menu

For example, the screen below shows values circled that fail validation with this custom formula:

=AND(LEFT(A1)="z",LEN(A1)=5)

Data validation invalid values circled on worksheet

Find cells with data validation

To find cells with data validation applied, you can use the Go To > Special dialog. Type the keyboard shortcut Control + G, then click the Special button. When the Dialog appears, select «Data Validation»:

Go to special button

Select data validation with go to special dialog

Copy data validation from one cell to another

To copy validation from one cell to other cells. Copy the cell(s) normally that contain the data validation you want, then use Paste Special + Validation. Once the dialog appears, type «n» to select validation, or click validation with the mouse.

Using paste special to copy data validation

Note: you can use the keyboard shortcut Control + Alt + V to invoke Paste Special without the mouse.

Clear all data validation

To clear all data validation from a range of cells, make the selection, then click the Data Validation button on the Data tab of the ribbon. Then click the «Clear All» button:

Use the Clear All button to remove data validationhttps://exceljet.net/sites/default/files/images/articles/inline/Clear%20all%20to%20remove%20data%20validation%20completely.png

To clear all data validation from a worksheet, select the entire worksheet, then, follow the same steps above.

Понравилась статья? Поделить с друзьями:
  • Validation in excel cell
  • Valera excel 2000 ionic купить
  • Valentines day word find
  • Valentine puzzle word search
  • Valentine day word search ответы