Field Guide

Data validation in Excel: Allow rules, input messages, and error alerts

Updated

Data validation in Excel controls what a cell will accept. Select the cell or range, choose Data > Data Validation, and on the Settings tab pick an Allow rule: a whole number inside a range, a value from a list, a date, a text length, or a Custom formula. Excel then checks each value as it is typed against that rule. That is the core of the feature. How much it actually protects comes down to two choices the same dialog holds: the Error Alert style, because only one of them blocks a bad entry, and the fact that the check runs on typing alone.

Microsoft documents the same three-tab dialog for Excel on Windows, Mac, and the web, across Excel 2016 through 2024 and Microsoft 365. On Windows the command sits at Data > Data Tools > Data Validation. A drop-down list, the control most people picture first, is one of these rules, the List type; building one from a range, a table, or typed entries is covered in creating a drop-down list. Every other Allow rule, plus the Error Alert that decides whether a bad entry is actually stopped, works from the same dialog.

How do you add a validation rule?

Select the cells, open Data > Data Validation, and go to the Settings tab. The Allow box holds the rule types:

For every type except List and Custom, the Data box sets the comparison, between, greater than or equal to, less than or equal to, and the like, and you fill in a Minimum and Maximum or a single value. To cap a figure at 25, for example, set Allow to Whole number, set Data to less than or equal to, and enter 25 in the Maximum box.

A Custom rule is the open-ended one: the entry is accepted only when a formula you supply evaluates to TRUE for that cell. Microsoft’s own example holds a product code to a fixed prefix and a minimum length:

=AND(LEFT(C2,3)="ID-",LEN(C2)>9)
The entry in C2 is accepted only when the whole formula is TRUE: it has to start with ID- and, per the boxed test, run to more than nine characters.

The formula can use the same logical functions you would put in an IF formula; validation reads its TRUE or FALSE instead of showing a result in the cell.

What does the Input Message tab do?

The Input Message tab shows a prompt when the cell is selected, before anyone types. Check Show input message when cell is selected, then give it a title and a short message, a note to pick a value from the list or to enter a date in the current quarter. It is guidance rather than a restriction: it appears on selection and does nothing to whatever value gets entered. The Error Alert tab is where the enforcement lives.

Stop, Warning, or Information: which alert blocks a bad entry?

The Error Alert tab decides what happens when someone types a value the rule rejects, and the Style box offers three that behave very differently:

So Warning and Information report a problem without preventing it, and the value can end up in the cell either way. If the rule is meant to hold, the style has to be Stop. Reading Warning or Information as a guarantee that bad data cannot get in is the usual mistake here.

Why a rule covers less than you expect

A validation rule is narrower than a first look suggests, in two ways that matter for data quality.

First, it reacts to direct typing only. The reason is in Microsoft’s description of when validation runs: “Data validation is designed to show messages and prevent invalid entries only when users type data directly in a cell.” A value that arrives by paste, by dragging the fill handle, or as a formula result is never tested, so an out-of-range number can sit in a cell that carries a strict rule without ever tripping it.

Second, a rule does nothing to values that were already in place when you added it. Excel does not go back and re-check existing contents, so a column you validate today keeps whatever it held yesterday, valid or not, until something re-enters each cell.

How do you find data that already breaks a rule?

Because validation ignores pasted, calculated, and pre-existing values, Excel keeps a separate audit for them. On the Data tab, in the Data Tools group, select the arrow next to Data Validation and choose Circle Invalid Data. Excel draws a red circle around every cell whose current value fails its rule, wherever that value came from, so you can work through them. Fixing a cell clears its own circle, and Clear Validation Circles on the same menu removes them all at once. This is what turns validation from a guard on new typing into a check you can run across data that is already in the sheet.

How do you change or remove a rule?

Reopen Data > Data Validation on a cell that carries the rule. To adjust it, edit the Allow, Data, or message settings and select OK; checking Apply these changes to all other cells with the same settings pushes the edit to every cell sharing the rule in one pass. To take the rule off, go to the Settings tab and select Clear All, then OK. Removing a rule never touches the values already in the cells, it only stops restricting what gets entered next, the same reason a drop-down’s picked values survive after its list is cleared.

The short version

A validation rule is a guard on new entries, which is why the problems it is meant to prevent still turn up elsewhere in a workbook. A number stored as text that was pasted in, a stale value that predates the rule, a formula result that fails a check without any warning, none of these are what validation was watching for. The rule keeps typed entries honest; auditing the values that got in another way is a separate job.

Frequently asked questions

How do I add data validation in Excel?
Select the cell or range you want to control, then on the Data tab, in the Data Tools group, select Data Validation. On the Settings tab, open the Allow box and choose a rule type such as Whole number, Decimal, List, Date, Time, Text length, or Custom. Set the Data condition and any minimum, maximum, or specific value it needs, then select OK. From then on Excel checks each value typed into those cells against the rule.
What is the difference between Stop, Warning, and Information error alerts?
The Error Alert style decides what happens when someone types a value that breaks the rule. Stop is the only one that blocks the entry: it offers Retry or Cancel and will not let an invalid value stay. Warning shows the message and asks the user to choose Yes to keep the value or No to edit it, so an invalid entry can remain. Information only shows the message, and the user clicks OK to keep the value or Cancel to reject it. Pick Stop when the rule must hold, and Warning or Information when you only want to flag a value while still allowing it.
Does data validation stop invalid data from getting into a cell?
Only in a narrow case. Validation checks a value while it is typed directly into the cell, and only a Stop error alert actually blocks it. A value that arrives by paste or by a fill is not checked, so it can bypass the rule, and validation does not review data that was already in the cell before the rule was added. A rule guards typed entries into the cells you set it on, not the whole column and not values that get in another way.
How do I find data that already breaks a validation rule?
Validation does not flag values that were in the cells before the rule existed, or ones that arrived by paste or as a formula result. To mark them, on the Data tab, in the Data Tools group, select the arrow next to Data Validation and choose Circle Invalid Data. Excel draws a red circle around every cell whose value fails its rule so you can find and fix each one. Choose Clear Validation Circles from the same menu to remove the circles, and fixing a value clears its own circle.
How do I make a drop-down list with data validation?
A drop-down list is the List rule. Select the cells, open Data Validation, set the Allow box to List, and point the Source at your entries, either a range on a sheet or a short comma-separated list typed into the box. Keep In-cell dropdown checked so the arrow appears. The List type is one of the Allow options; the full walkthrough for a drop-down, including tables and named ranges, is a separate guide.
How do I remove or change a data validation rule?
Select a cell that carries the rule, then on the Data tab select Data Validation. To change the rule, edit the Allow, Data, or message settings and select OK; check Apply these changes to all other cells with the same settings so every matching cell updates. To remove the rule, go to the Settings tab and select Clear All, then OK. Removing the rule leaves any values already in the cells untouched; it only stops restricting what comes next.

Catch the errors before they ship

Reviewing a change to a model? Compare the two versions in your browser and see every changed cell, formula, and value. It's free, and nothing leaves your computer.