Validating Input: Lists, Limits and Rules

First lesson of the Build and Safeguard a Reliable Excel Workbook course, free to read: about 15 minutes, 3 exercises and 3 quiz questions. This is the catalogue's base lesson; in the student space, it is rewritten for your profile.

Objectives

  • Create validation rules (list, whole number, date, custom)
  • Write a suitable input message and error alert
  • Find existing data that does not comply with the rules

Data validationDrop-down listCustom validation rule

Why validate input?

A reliable workbook starts with clean data at the point of entry. A region typed as “nord” instead of “Nord”, a negative quantity or a date in 2062 silently skews totals, SUMIFS (SOMME.SI.ENS) formulas and PivotTables. Rather than fixing things afterwards, Excel lets you prevent incorrect entries with data validation.

You will find it under Data > Data Tools > Data Validation. The dialog box has three tabs:

  • Settings: the rule type (Allow) and its parameters;
  • Input Message: a tooltip that appears when the cell is selected;
  • Error Alert: what happens when the entry violates the rule.

Rule types

Allow Typical use Example parameters
Whole number quantities, headcounts between 1 and 100
Decimal prices, rates greater than or equal to 0
List regions, statuses, products source =ListeRegions
Date order dates between 01/01/2026 and 31/12/2026
Text length codes, references equal to 8
Custom any rule expressed as a formula =NB.SI($A$2:$A$200;A2)=1

Select the whole range to protect (for example E2:E200) before opening the dialog box: the rule applies to every selected cell.

The List type displays an arrow in the cell. You can type the source directly (Nord;Sud;Est;Ouest in a French-language Excel), but it is better to place it on a settings sheet:

  1. on a sheet named Listes, enter the regions in a column;
  2. select them and type ListeRegions in the Name Box (to the left of the formula bar), then press Enter;
  3. in the validation, choose List and enter the source =ListeRegions.

Adding a region then happens in one place only. If the list is a column of a structured table, define a name that points to that column: a validation source does not directly accept the Table[Column] syntax, but it does accept a name.

In Microsoft 365, a list can also point to a dynamic result: if J2 contains =TRIER(UNIQUE(Ventes[Produit])) (SORT(UNIQUE(...))), the source =$J$2# automatically follows the size of the list.

Messages and alerts

An input message guides the user (“Whole quantity between 1 and 100”). The error alert has three styles:

  • Stop: the entry is rejected (only Retry and Cancel are offered);
  • Warning: Excel asks for confirmation, and the user can override it;
  • Information: a simple notice, the value is accepted.

For data that feeds calculations, choose Stop and a message that says what to do, not just “error”.

Custom rules

The Custom type accepts a formula that must return TRUE (VRAI). It is written for the first cell of the selection, with relative references for the cell being tested:

=NB.SI($A$2:$A$200;A2)=1            rejects a duplicate in column A
=ET(E2>=1;E2<=100;ENT(E2)=E2)       whole number between 1 and 100
=ESTNUM(CHERCHE("@";F2))            the address contains an @

The limits, and how to compensate for them

Validation only checks entry. A copy and paste replaces the target cell, rule included, and data present before the rule was created is not checked. Two habits help:

  • Data > Data Validation > Circle Invalid Data: Excel circles in red every cell that breaks its rule; Clear Validation Circles removes them;
  • to paste without destroying the rules, use Paste Special > Values.

Finally, validation does not replace the consistency checks you will see at the end of the course: it filters typing errors, not reasoning errors.

Exercises

Solutions and tests stay on the server. In the student space, your code is run and checked, and the tutor gives hints before the solution.

  1. TaskDifficulty 22 hints

    Secure an input sheet

    Enter this data starting from cell A1 of the Saisie sheet (or paste it into column A, then use Data > Text to Columns, semicolon delimiter):

    Date;Commercial;Region;Produit;Quantite
    05/03/2026;Alice;Nord;Clavier;10
    06/03/2026;Bruno;Sud;Souris;0
    07/03/2026;Chloe;Centre;Ecran;4
    08/03/2026;David;Ouest;Clavier;150
    09/03/2026;Alice;Nord;Souris;20

    Then, on a sheet named Listes:

    Region;Commercial
    Nord;Alice
    Sud;Bruno
    Est;Chloe
    Ouest;David
    1. Name A2:A5 of the Listes sheet ListeRegions and B2:B5 ListeCommerciaux.
    2. On Saisie!C2:C100, create a drop-down list with source =ListeRegions; on B2:B100, a list with source =ListeCommerciaux.
    3. On E2:E100, allow a whole number between 1 and 100, with the input message “Whole quantity from 1 to 100” and a Stop style alert.
    4. On A2:A100, allow a date between 01/01/2026 and 31/12/2026.
    5. Run Circle Invalid Data.
    • The names ListeRegions and ListeCommerciaux exist in the Name Manager
    • Cells C2 and B2 display a drop-down list arrow
    • Entering 150 in E7 is rejected by a stop alert
    • Exactly three cells are circled: E3, C4 and E5
  2. TaskDifficulty 22 hints

    Forbid duplicate references

    On a new sheet named Produits, enter the header Reference in A1, then apply to A2:A50 a Custom validation that rejects:

    • any reference already present in the column;
    • any reference whose length is not 6 characters.

    Then test by entering, in order: CLA001 (A2), SOU002 (A3), CLA001 (A4), ECR03 (A4), ECR003 (A4).

    • The validation formula is =ET(NB.SI($A$2:$A$50;A2)=1;NBCAR(A2)=6) or equivalent
    • The range $A$2:$A$50 is absolute and the tested cell A2 is relative
    • Entering CLA001 in A4 is rejected (duplicate)
    • Entering ECR03 in A4 is rejected (5 characters)
  3. Multiple choiceDifficulty 11 hint

    Alert style

    You want an out-of-range quantity to be impossible to enter. Which alert style do you choose?

    • Information
    • Warning
    • Stop
    • None, the rule is enough

End-of-lesson quiz

  1. Where is the data validation command located?

    • Home > Conditional Formatting
    • Data > Data Tools > Data Validation
    • Review > Protect Sheet
  2. What happens when you paste a value onto a validated cell?

    • The paste is always rejected
    • The pasted cell replaces the target cell, validation rule included
    • Excel converts the value so that it complies with the rule
  3. In a custom rule applied to B2:B100, which formula tests that each value is positive?

    • =$B$2>0
    • =B2>0
    • =SOMME(B2:B100)>0

The rest of the course

  1. Names and Structured Tables15 min
  2. Dynamic Array Functions: FILTER, UNIQUE, SORT20 min
  3. Assumptions, Scenarios and Goal Seek20 min
  4. Best Practices and Formula Auditing20 min

Build and Safeguard a Reliable Excel Workbook · Intermediate · 1 h 30 min