Ravindra BagaleCourses & study guides Track your progress

Chapter 34

Excel

Data Validation: Complete Guide

Build rock-solid Excel forms with Data Validation: dropdown lists, whole numbers and decimals, dates, text length, custom formulas, and dependent Region→City lists. The practice workbook already has working rules — try to break them.

Ravindra Bagale’s Tip

After you set a rule, type a wrong value into one of its cells and press Enter. If Excel stays silent, check four things: the rule covers the right cells, Show error alert is ticked, the Style is Stop, and you typed the value instead of pasting it.

About this data. Order and employee forms mix Indian and foreign names with INR prices and 2026 dates. The Lists sheet holds the Region, City, Status and Dept lists. All names, orders and amounts are fictional and made up for practice.

1. Why data validation matters

Validation is cheaper than cleaning the same column every Monday.

What: Data validation is a rule on a column that controls what a person can type or pick in its cells.

Why: A wrong spelling or the wrong kind of value in a column breaks totals, PivotTables and Power Query merges. A rule at the moment of typing stops the mistake before it spreads.

How:

  1. Decide which columns must stay clean (Region, Qty, Date, Email).
  2. Data → Data Validation on the input range.
  3. Set Allow type, Input Message, and Error Alert.
  4. Test with a wrong value — Excel should block or warn.
Before / setupRule or formulaResultMeaning
Region free text “Wesst”List: West/South/NorthDropdown onlyNo more typos

2. Dropdown lists (typed or range)

Keep list sources on a Lists sheet so business users can add items without editing the rule.

What: A list rule lets a person pick a value only from a fixed set of allowed values shown in a drop-down.

Why: Columns such as Status and Department must use the same words every time, so counts and filters group the rows correctly.

How:

  1. Select the Status cells (D2:D11).
  2. Data → Data Validation → Allow: List.
  3. Source: select Lists!E2:E5 (or type the commas).
  4. Optional: tick In-cell dropdown. Add Input Message “Pick a status”.
  5. Error Alert Style: Stop (hard block) or Warning.
Before / setupRule or formulaResultMeaning
Status columnList → Lists!$E$2:$E$5Dropdown appearsControlled vocabulary

3. Whole numbers and decimals

Match the rule to the real business limit — do not invent 1–9999 if stock max is 500.

What: A whole number rule or a decimal rule accepts only numbers inside the minimum and maximum you set.

Why: Qty must be a whole count and Price must not be below zero, because a wrong number here gives wrong order values.

How:

  1. Select Qty cells → Data Validation → Whole number → between 1 and 500.
  2. Select Unit price → Decimal → greater than 0.
  3. Write a clear Error Alert: “Qty must be a whole number from 1 to 500”.
  4. Try typing 0 or 12.5 — confirm the alert.
Before / setupRule or formulaResultMeaning
Qty = 12.5Whole number 1–500Excel blocks entryInteger only

4. Dates and text length

Date rules stop “02/30/2026” style chaos when people type by hand.

What: A date rule accepts only dates between a start date and an end date. A text length rule limits how many characters a cell can hold.

Why: Order Date must stay inside the period the report covers, and short notes stay readable when the sheet is exported to another system.

How:

  1. Select Order date → Date → between DATE(2026,1,1) and DATE(2026,12,31) — or pick cells with those dates.
  2. Select Notes → Text length → less than or equal → 40.
  3. Test a 2025 date and a 50-character note.
Before / setupRule or formulaResultMeaning
Notes 50 charsText length ≤ 40RejectedKeeps CSV columns tidy

5. Custom formulas (unique, email, phone)

Write the formula as if for the first cell in the range; Excel adjusts rows.

What: A custom rule uses a formula that must return TRUE before Excel accepts the typed value. Excel reads the formula as written for the active cell of the selected range and adjusts it for every other cell.

Why: Some checks depend on the other values in the column or on the characters inside the text, and a fixed list or a number range cannot express them.

How:

  1. Select Employee ID A2:A9 → Custom → =COUNTIF($A$2:$A$9,A2)=1
  2. Select Email → Custom → =ISNUMBER(SEARCH("@",B2)). This is only a simple contains-@ teaching rule: it still accepts an @ on its own and person@@example.com, and no formula can prove that an address really receives mail.
  3. Format the Phone cells as Text first, so a phone number that starts with 0 keeps its first digit. Then select Phone → Custom → =AND(LEN(D2)=10,SUMPRODUCT(--ISNUMBER(FIND(MID(D2,ROW($1:$10),1),"0123456789")))=10). LEN checks that there are exactly ten characters, and the FIND part checks that every one of them is a digit.
  4. Error alerts should say what to fix, not only “Invalid”.
Before / setupRule or formulaResultMeaning
Duplicate E-1001COUNTIF(...)=1Second entry blockedUnique key

6. Dependent dropdowns (Region → City)

Each named range must have the same name as an item in the parent list. Spelling and spaces matter, but Excel names ignore capital letters.

What: A dependent drop-down is a list rule whose allowed values change with the value picked in another column.

Why: The City column must offer only the cities of the region picked in the Region column, so nobody can pick a city from the wrong region.

How:

  1. On Lists sheet, put West cities in B2:B4, South in C2:C4, North in D2:D4.
  2. Formulas → Name Manager → define names West, South, North pointing at those ranges (each name must be spelled the same as a Region item; Excel names ignore capital letters).
  3. Region column: List → Lists!$A$2:$A$4.
  4. City column: List → Source =INDIRECT(A2).
  5. Change Region from West to South — City dropdown updates.
Before / setupRule or formulaResultMeaning
Region WestINDIRECT(A2) → West citiesPune/Mumbai/AhmedabadCascading lists

7. Circle invalid data, copy, and clear

Circling does not fix data — it only shows what still breaks the rule.

What: Circle Invalid Data marks every existing cell that breaks its rule, and Clear Validation Circles removes those marks.

Why: A new rule checks only values typed after it was added, so values typed earlier can still break it.

How:

  1. On OrderForm, temporarily type a bad Qty (use Warning style if Stop blocks you, or clear the cell rule briefly).
  2. Data → Data Validation dropdown arrow → Circle Invalid Data.
  3. Fix the cells, then Clear Validation Circles.
  4. To remove rules: select range → Data Validation → Clear All.
Before / setupRule or formulaResultMeaning
Legacy bad QtyCircle Invalid DataRed ovals appearAudit before share

8. Design tips for solid forms

Teach users the Input Message — a good prompt cuts support questions.

What: Good validation design keeps the allowed values on a separate Lists sheet, uses named ranges that cover the whole list, protects the Lists sheet, and notes the rule type in the column header.

Why: A rule stops working when its source range no longer covers the whole list, or when someone overwrites the allowed values.

How:

  1. Keep one Lists sheet; hide it if needed.
  2. Use tables or dynamic named ranges when lists grow often.
  3. Protect sheet but allow selecting unlocked input cells.
  4. Pair validation with Conditional Formatting blanks for a second safety net.
Before / setupRule or formulaResultMeaning
Growing city listTable or dynamic nameDropdown stays currentLess maintenance

Practice tasks (12)

  1. On OrderForm row 5, pick Region South and Status Open from the dropdowns.
    Hint

    Use the in-cell arrows.

  2. Try Qty = 0 on row 5 — confirm the whole-number alert.
    Hint

    Rule is between 1 and 500.

  3. Enter Unit price -10 — confirm decimal > 0 blocks it.
    Hint

    Error Alert on column F.

  4. Type a 2025-01-01 order date — confirm year-2026 rule.
    Hint

    Date between Jan–Dec 2026.

  5. Type a note longer than 40 characters into a Notes cell and press Enter — confirm that the Stop alert blocks it. Then copy the same long note from another cell and paste it into Notes. Excel accepts the pasted note without any alert, so run Circle Invalid Data to find it.
    Hint

    The Notes rule checks what you type. Pasting skips the check, so Circle Invalid Data is how you catch pasted mistakes.

  6. On CustomRules, duplicate E-1001 on a new row — confirm unique rule.
    Hint

    COUNTIF custom formula.

  7. Enter an email without @ and confirm that the simple contains-@ rule blocks it. Then enter person@@example.com and notice that the rule accepts it, because it checks only that an @ sign is present.
    Hint

    SEARCH("@",…) formula.

  8. Enter phone 12345 — confirm 10-digit rule. Then try +123456789, which has ten characters but not ten digits, and confirm that the rule blocks it too.
    Hint

    LEN counts the characters, and the FIND part checks that every character is a digit.

  9. On Dependent, set Region to North and pick Lucknow.
    Hint

    INDIRECT named range North.

  10. Change that row’s Region to West — City must be re-picked from West list.
    Hint

    Old city may no longer be valid.

  11. Circle Invalid Data on OrderForm after planting one bad value, then clear circles.
    Hint

    Data Validation menu arrow.

  12. Add a new city “Surat” under West on Lists and use it in Dependent (extend named range if needed).
    Hint

    Update name West to include the new cell.

Quick quiz

Q1. Data Validation lives on which ribbon tab?

Q2. A dropdown of fixed words uses Allow type…

Q3. Dependent City lists usually use which function in Source?

Q4. To block duplicate IDs you typically use…

Q5. Circle Invalid Data does what?

Q6. Text length ≤ 40 is best for…

Q7. Named range for region West must…

Q8. Error Alert style Stop means…

End-of-chapter checklist

  • I can build List, Whole, Decimal, Date, and Text length validations with clear alerts.
  • I can write Custom formulas for unique IDs and a simple contains-@ email check and a phone check.
  • I can build dependent dropdowns with named ranges and INDIRECT.
  • I can Circle Invalid Data and Clear All validation when needed.

Quick revision cards

Three revision cards for this chapter. Each card explains one idea with its own example.

Dropdown lists revision card
Dropdown lists
Numbers dates text length card
Numbers, dates, length
Custom and dependent lists card
Custom & dependent