ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Data tools
  3. Data Validation Rules in Excel: Limit What Users Can Enter

Data Validation Rules in Excel: Limit What Users Can Enter

By ExcelReady Team·Updated November 2, 2026·6 min read

The short answer

Select the cells, go to Data > Data Validation, and choose what to allow: a whole number, decimal, list, date, time, text length or a custom formula. Set the limits, add an input message and an error alert, and click OK. Excel then rejects typed entries that break the rule. Custom rules use any formula that returns TRUE for valid entries.

Key takeaways

  • Data validation is on the Data tab: pick a type, set the limits, then add an input message and an error alert.
  • A custom rule is a formula that must return TRUE for the entry to be accepted, such as =AND(ISNUMBER(B2),B2>=1,B2<=50).
  • Write the custom formula for the top-left cell of your selection; Excel adjusts it for the other cells.
  • Validation only checks what people type. Pasted values and data that was already there are not checked.
  • Use Circle Invalid Data to find entries that break the rule after the fact.
On this page+
  1. How to add a data validation rule
  2. The built-in rule types
  3. How to write a custom validation rule
  4. Why use ISNUMBER in a custom rule?
  5. Test the rule in a cell first
  6. Input messages and error alerts
  7. What data validation can't do
  8. Practise it

Data validation rules in Excel limit what people can type into a cell: only whole numbers from 1 to 50, only dates this year, only items from a list, or only codes that are exactly six characters long. You set them once, and Excel rejects wrong entries with a message. This guide covers the built-in rule types, custom formula rules with AND, ISNUMBER and LEN, and the limits you should know before you rely on them.

How to add a data validation rule#

A data validation rule is set from the Data tab in four steps:

  1. Select the cells to control, for example B2:B200.
  2. Go to Data > Data Tools > Data Validation. On Windows, the keyboard path is Alt, A, V, V.
  3. On the Settings tab, choose what to allow in the Allow box, then set the limits.
  4. Click OK.

Now type 75 into a cell that only allows 1 to 50, and Excel shows an error and refuses the entry. The rule stays with the cell when you sort or fill it down.

The Ignore blank box is ticked by default. It means an empty cell is always allowed. Untick it only if blanks should count as errors, and remember that it doesn't force anyone to fill the cell in.

The built-in rule types#

The Allow box offers eight options. Each one has its own limits, such as between, greater than or equal to.

AllowWhat it acceptsExample rule
Any valueEverything (no rule)Used to switch a rule off
Whole numberIntegers onlyBetween 1 and 50
DecimalAny numberGreater than or equal to 0
ListOnly items from a listPending, Shipped, Delivered
DateDates onlyBetween 1/1/2026 and 31/12/2026
TimeTimes onlyBetween 9:00 and 17:00
Text lengthText with a set number of charactersEqual to 6
CustomAnything your formula returns TRUE for=AND(ISNUMBER(B2),B2>=1,B2<=50)

The List type creates a drop-down list. The guide to creating a drop-down list in Excel covers it step by step, and how to make a drop-down list that grows with your data shows how to keep it up to date. Limits can also point at cells. For example, a Date rule with a start date of =TODAY() blocks past dates.

How to write a custom validation rule#

A custom rule is a formula that returns TRUE when the entry is allowed and FALSE when it isn't. TRUE and FALSE are logical values, and comparisons like B2>=1 produce them. If you're new to this, practise TRUE and FALSE comparisons first.

Write the formula for the top-left cell of your selection. If you selected B2:B200, write it for B2. Excel moves the reference down for each cell, just as it does when you fill a formula down. Use $ signs for anything that must stay fixed, like a list range.

Here are custom rules that come up often:

RuleCustom formula (for cell A2 or B2)
Exactly 6 characters=LEN(A2)=6
Starts with "EM" and is 6 characters=AND(LEFT(A2,2)="EM",LEN(A2)=6)
A number from 1 to 50=AND(ISNUMBER(B2),B2>=1,B2<=50)
No duplicates in A2:A200=COUNTIF($A$2:$A$200,A2)=1
No spaces at the start or end=A2=TRIM(A2)
Text only, no numbers=ISTEXT(A2)

AND returns TRUE only when every test inside it is TRUE. OR returns TRUE when at least one test is TRUE. The AND function guide explains both, and you can practise AND, OR and NOT in a live spreadsheet. LEN counts characters, including spaces; see the LEN function guide.

Why use ISNUMBER in a custom rule?#

ISNUMBER makes sure the entry is a real number, not text. Without it, a rule such as =B2>=1 can accept text: in Excel, any text is treated as greater than any number in a comparison, so "ten" passes B2>=1. Adding ISNUMBER closes that gap:

Excel formula
=AND(ISNUMBER(B2),B2>=1,B2<=50)

The ISNUMBER function guide and the article on ISBLANK, ISNUMBER and ISTEXT cover the other IS functions. To use them confidently, practise the IS functions.

Test the rule in a cell first#

A custom rule gives no feedback while you write it, so test it in a normal cell first. Type the same formula next to your data and fill it down. Every row shows TRUE or FALSE, and you can see which entries would pass.

ABD
1Order IDQtyValid?
2EM104212TRUE
3EM1043130FALSE
4EM104475FALSE
5EM1045tenFALSE

The test formula in D2 is =AND(LEN(A2)=6,ISNUMBER(B2),B2>=1,B2<=50). Row 3 fails because the ID has 7 characters. Row 4 fails because 75 is over 50. Row 5 fails because "ten" is text. Once the results look right, copy the formula into the Custom box and delete the test column.

To count how many rows break the rule in one cell, use SUMPRODUCT: =SUMPRODUCT((LEN(A2:A5)<>6)*1) counts IDs that are not 6 characters long (here, 1).

Input messages and error alerts#

An input message tells people the rule before they type, and an error alert tells them what went wrong. Both are tabs in the Data Validation box.

  • Input Message: a short note that appears when the cell is selected, such as "Enter a quantity from 1 to 50."
  • Error Alert: the message shown when the rule is broken. Choose one of three styles.
StyleWhat happens
StopThe entry is refused. The user must retry or cancel.
WarningThe user is asked "Continue?" and can accept the wrong value.
InformationThe user is told, but the value is accepted.

Use Stop for rules that must hold, like IDs that feed a lookup. Use Warning for soft limits, like an unusually large order. Write the message in plain words: say what is allowed, not just "Invalid entry".

What data validation can't do#

Data validation is a guide for people typing, not a lock. Know its limits:

  • Pasting replaces the rule. If someone copies a cell and pastes it over a validated cell, the pasted cell's rules (or none) replace yours. Excel doesn't check the pasted value.
  • Old data isn't checked. Adding a rule doesn't flag values already in the cells. Use Data > Data Validation (arrow) > Circle Invalid Data to circle them in red.
  • Formulas aren't checked. Validation only applies to values typed into the cell, not to results calculated by a formula.
  • Lists can point to other sheets. You can use a range on another sheet as the source, as the guide to a drop-down list from another sheet shows.

For real control, combine validation with sheet protection. The guide to protecting a sheet and locking cells shows how to leave only the input cells editable.

Practise it#

Every custom rule is a TRUE or FALSE formula, so the formula skill is what you need to practise. Practise AND, OR and NOT in a live spreadsheet, then practise the IS functions: you type each test and ExcelReady checks it instantly. Start with the row-3 test in the exercise on this page.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

The rule is: the Order ID must be exactly 6 characters and the quantity must be a number from 1 to 50. Click D3 and test row 3 with AND, LEN and ISNUMBER (it should return TRUE or FALSE).

fx
ABCDE
1
Order ID
Qty
Notes
2
EM1042
12
Row 3 valid?
3
EM10431
30
4
EM1044
75
5
EM1045
ten
6
EM1046
8
7
8
9

Tip: AND returns TRUE only when every test is TRUE. Test LEN(A3)=6, ISNUMBER(B3), B3>=1 and B3<=50.

Practise this in a lesson

LessonTRUE, FALSE and comparisonsAsk Excel yes-or-no questions with =, <>, >, <, >= and <=, and get TRUE or FALSE back. The building block of every IF.LessonAND, OR and NOTCheck several conditions at once with AND and OR, flip a result with NOT, and combine them inside IF.LessonIS functions and SWITCHCheck what's really in a cell with ISBLANK, ISNUMBER and ISTEXT, and turn short codes into labels with SWITCH.Function guideANDCheck that every condition is true with Excel's AND. Use it inside IF for bonuses, ranges and eligibility rules, then try a live exercise.Function guideISNUMBERUse ISNUMBER to catch numbers stored as text and, with SEARCH, to test whether a cell contains a word. Examples, pitfalls and live practice.Function guideLENCount characters with Excel's LEN: check length limits, find stray spaces and count commas with SUBSTITUTE. Examples and a live exercise.

Frequently asked questions

How do I set data validation rules in Excel?

+

Select the cells, go to Data > Data Validation, and on the Settings tab choose what to allow, such as Whole number between 1 and 50. Add an input message and an error alert on the other tabs, then click OK.

How do I use a custom formula in data validation?

+

Choose Custom in the Allow box and type a formula that returns TRUE for valid entries, written for the first selected cell. For example, =LEN(A2)=6 allows only entries that are exactly six characters long.

Why does data validation not stop pasted values?

+

Pasting a cell replaces its validation rule along with its value, so Excel doesn't check it. Protect the sheet or check the data afterwards with Circle Invalid Data.

How do I prevent duplicate entries with data validation?

+

Use a custom rule with COUNTIF, such as =COUNTIF($A$2:$A$200,A2)=1 for cells A2:A200. Excel then rejects a value that already appears in the range.

How do I remove data validation from cells?

+

Select the cells, open Data > Data Validation and click Clear All, then OK. This removes the rule but keeps the values already in the cells.

Sources

  • Apply data validation to cells - Microsoft Support
  • AND function - Microsoft Support
  • IS functions - Microsoft Support

Written and checked by the ExcelReady Team. First published November 2, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. How to add a data validation rule
  2. The built-in rule types
  3. How to write a custom validation rule
  4. Why use ISNUMBER in a custom rule?
  5. Test the rule in a cell first
  6. Input messages and error alerts
  7. What data validation can't do
  8. Practise it

Keep reading

Data tools· 5 min read

Create a Drop-Down List in Excel

To create a drop-down list in Excel, select the cells, go to Data > Data Validation, set Allow to List, and in Source either type the items separated by commas (Open,Closed) or select a range that holds them. Click OK. Each cell now shows an arrow, and Excel rejects entries that aren't on the list.

Dynamic arrays· 5 min read

Dynamic Drop-Down Lists in Excel That Update Themselves

A dynamic drop-down list in Excel updates itself when the source data changes. The simplest way is to keep the items in an Excel table and use the table column as the Data Validation source. In Microsoft 365 or Excel 2021, build the items with =SORT(UNIQUE(A2:A50)) in a helper cell such as F2, then set the source to =$F$2#.

Data tools· 5 min read

Drop-Down List From Another Sheet in Excel

Keep the items on their own sheet, then select the cells for the drop-down and go to Data > Data Validation. Choose List, click in the Source box, switch to the other sheet and select the items, for example =Lists!$A$2:$A$6. A named range or a table column makes the list easier to read and lets it grow.

More on data tools

  • How to Make a Dependent Drop-Down List in Excel
  • Find Duplicates Between Two Columns in Excel
  • How to Filter Data in Excel (Ctrl+Shift+L)
  • How to Make a Frequency Table in Excel
  • How to Highlight Blank Cells in Excel
  • Highlight Cells That Contain Specific Text
All data tools articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free