Skip to main content
Bob Umlas/5 min read

Data Validation in Excel

Excel Power Features

Pivot Tables

Summarize and slice large datasets without writing formulas.

Power Query

ETL inside Excel — clean, reshape, merge, and load data sources.

Dynamic Arrays

FILTER, SORT, UNIQUE, SEQUENCE — modern Excel functions that spill.

XLOOKUP

Replaces VLOOKUP and HLOOKUP — exact match by default, works any direction.

Master Excel at Noble Desktop

Noble Desktop's Excel Bootcamp covers formulas, pivot tables, data analysis, and VBA.

Explore how to use data validation to set restrictions on cell entries, alert users, and prevent incorrect values from entering your data cells, with examples and step-by-step instructions.

Data validation is a way of ensuring the data in cells meets your defined restrictions. As a simple example, you can set it so that a cell must be a number less than 10. If you enter 11, you can alert the user with an appropriate message, as well as prevent the value from going into the cell. You might see this:

Excel data validation error message dialog preventing entry of a value that does not meet restrictions

There are many restrictions available. These are shown here:

Data Validation dialog showing the Settings tab with restriction options like Whole number, Decimal, List, and Date

Notice there are 3 tabs: Settings (shown), Input Message, and Error Alert. We’ll explore them all in this article.

You might ask, why would you ever apply a data validation setting of “Any value”. Why bother? Well, you can alert the user with information from the Input Message tab. You could see this, for example:

Excel input message appearing when clicking a cell with data validation set to Any value

That message would only show when you click the cell (unlike a note or comment which shows when you hover the mouse over the cell).

Let’s go back to the beginning and look at each of the other choices, beginning with Whole number.

When you use this option, you will see this dialog:

Data Validation Settings tab showing Whole number restriction with Between operator and two value fields

Notice all the choices available! The two edit boxes (covered) are for the values “between”… if you chose Greater than, for example, there would only be one edit box

If you click the Error Alert tab and enter your own message, like this, then that would be the error shown:

Data Validation Error Alert tab with custom error title and message configured

Custom error alert dialog displayed when an invalid value is entered in a validated cell

The next choice, Decimal, is the same as Whole Number, except you can enter values such as 2.5 or 7.123456 instead of being restricted to 2 or 8, for example.

Next is List. This shows

Data Validation Settings tab showing the List option with a Source field for dropdown items

What goes in Source varies. You can type in a list, separated by commas such as:

Data Validation Source field with comma-separated values typed in for a dropdown list

And you would see this when you click on the cell containing this validation rule:

Excel cell showing a dropdown list created by data validation with typed comma-separated values

The Source can be a reference to cells, For example, this data validation:

Data Validation Settings tab with List source pointing to a cell range containing month names

Would show the months when you click the dropdown containing this rule:

Excel cell dropdown showing month names populated from a cell range reference in data validation


The source can also be a range name:

Data Validation Settings tab with List source using a named range reference

This could produce this list:

Excel cell dropdown showing values populated from a named range in data validation

Next, let’s look at Date. When you choose this, you have another variation of choices:

Data Validation Settings tab showing Date restriction with various comparison operators available

The rest of the dialog depends on this choice, similar to when you choose Whole Number. If you choose “between”, there will be 2 places to enter values. If you choose “greater than”, there will be one.

There are similar choices for when you choose Text Length. This, for example,

Excel cell showing a data validation error for text length exceeding the allowed maximum

Is achieved from these settings:

Data Validation Settings tab configured for Text Length restriction with specific length limitsData Validation Error Alert tab configured for the text length restriction

Next, and the most possibly complicated, is the choice for Custom. Suppose you wanted to ensure that the user enters a social security number with the correct format. You would need to endure it’s 11 characters long (9 numbers, 2 dashes), that the 4th and 7th characters are dashes, and the other 9 are numeric. The solution presented here is making sure the 9 numbers, when put together (without the dashes) and multiplied by 1 is not an error. That is, 123-45-6789 would check that 123456789 * 1 is a number, whereas 12W-45-6789 would multiply 12W456789 by 1 which would be an error. Here’s the formula which does all that (the data validation cell is F2):

=AND(LEN(F2)=11, MID(F2,4,1)="-", MID(F2,7,1)="-", NOT(ISERROR(1*(LEFT(F2,3)&MID(F2,5,2)&RIGHT(F2,4)))))

Data Validation Custom formula for validating Social Security number format with dashes and digits

(the formula doesn’t all show!)

Let’s examine some real-world examples.

Allow only text:

Data Validation Custom formula using ISTEXT function to allow only text entries in cells

Allow only larger-than-previous values

Data Validation Custom formula ensuring each value is larger than the previous cell value

The rule here was set up by selecting A2:A10 (not A1 – there’s no previous from A1), then using the formula =A2>A1 (A2 was the active cell).

Don’t allow duplicate values.

Data Validation Custom formula using COUNTIF to prevent duplicate values in a range

Here, A1:C20 was first selected, and the rule shown was entered (note the absolute reference to A1:C20, and the relative reference to A1 (A1 was the active cell).

Cascading:


Cascading data validation dropdowns showing Fruit selected in A2 with fruit items in B2 dropdown

A2’s Data Validation is as shown, but B2’s depends on A2’s. Notice Fruit was selected in A2. Then the choices in B2 are as shown. But if Cars were selected in A2:

Cascading data validation with Cars selected in A2 showing car brands in B2 dropdown

Then you see cars in B2. How is this done?

The solution is in the formula in the data validation:

Data Validation Settings tab showing INDIRECT function formula for cascading dropdown lists

Perhaps the INDIRECT function is new to you. Here’s a simple explanation. =INDIRECT(A2) says treat the contents of A2 as a reference. If cell A2 contained G4:G10, then that text, treated as a reference, is the contents of those cells:

Excel example demonstrating the INDIRECT function treating cell contents as a cell reference

By naming ranges “Cars”, “Fruit”, “Vegetables”, and “States”, it fills the requirements:

These names were defined like this:

Name Manager showing named ranges for Cars, Fruit, Vegetables, and States used in cascading validation

Allow entries only if it begins with a certain letter:

Data Validation Custom formula restricting entries to begin with a specific letter

A few miscellaneous items to discuss. In the Error Alert tab, you can choose whether to prevent such an entry or allow it with a warning, or just give information:

Data Validation Error Alert tab showing Stop, Warning, and Information style options

Each has its own icon. Above is the stop. Here’s the Warning:

Warning style error alert dialog with Yes and No buttons allowing the user to proceed or retry

Here’s the Information:

Information style error alert dialog with OK button providing a non-blocking notification

At the bottom of the Settings tab is a checkbox:

Data Validation Settings tab showing the Apply these changes to all other cells with the same settings checkbox

If you’ve selected many cells and put in some data validation rules, then decide you need to change something, selecting this checkbox will make the same changes to all cells with the same settings.

You’re now an expert in Data Validation!