MSBA-175 · Lesson 4 of 12 · 21 min
Data validation
▶ Video coming soon A video version of this lesson is on the way.
Conditional formatting shows problems after they happen. Data validation stops many of them happening at all. In early October, Rosalind decided that the three event coordinators should enter their own bookings into the season workbook instead of emailing them to Teo. Dagny's worry was obvious: three people typing package codes, dates and guest counts by hand would produce "GG", "Garden gold", "garden-gold" and a wedding dated in 2062. Her fourth session built the input sheet so that it accepts only sensible values. The exam lists this as configure data validation, and it appears in many projects because it combines with named ranges, tables and formulas.
The Data Validation dialog
Select the input cells and choose Data > Data Tools > Data Validation. The dialog has three tabs. Settings defines what is allowed. Input Message shows a note when the cell is selected. Error Alert decides what happens when someone types something that is not allowed.
| Allow | Accepts | Maple & Pine example |
|---|---|---|
| Any value | Anything (the default; used to show an input message only) | Notes column with an input message |
| Whole number | Integers with a condition such as between, greater than | Guests: between 2 and 400 |
| Decimal | Numbers with a condition | Deposit share: between 0 and 1 |
| List | Entries from a typed list or a range, with an in-cell drop-down | Package code from the Packages table |
| Date | Dates with a condition | Event date: between today and December 31, 2028 |
| Time | Times with a condition | Ceremony start: between 9:00 and 20:00 |
| Text length | Text whose length meets a condition | Booking code: length exactly 11 |
| Custom | Any formula that returns TRUE for valid entries | No duplicate booking codes |
Every type except Any value and Custom takes a Data operator (between, not between, equal to, not equal to, greater than, less than, greater than or equal to, less than or equal to) and one or two limits. The limits can be typed values, cell references or formulas, which is how a date rule can say "from today": Dagny entered =TODAY() as the start date for event dates and =DATE(2028,12,31) as the end date. Two check boxes complete the tab. Ignore blank lets cells stay empty. Apply these changes to all other cells with the same settings updates every cell sharing the rule when you edit it.
Drop-down lists from a range
List validation is the one used most. For a short fixed list you can type the entries in the Source box separated by commas, such as Paid,Due later,Overdue,Cancelled. For anything that changes, point the source at a range. Dagny's packages live in a table called Packages on the hidden Lists sheet. Data validation does not accept a structured reference such as Packages[Code] directly in the Source box, so there are two standard approaches.
=PackageCodes
=INDIRECT("Packages[Code]")
=Lists!$A$2:$A$4She created a name, PackageCodes, in Formulas > Name Manager, referring to =Packages[Code]. Because the name points at a table column, it grows when a new package is added to the table, and the drop-down follows automatically. The plain-range source in the third line would need editing every time.
A source can also be a dynamic array formula. In Microsoft 365, a reference to a spilled range with the # operator works in the Source box. Dagny keeps a sorted list of active venues spilled by a formula in the Lists sheet at D2, and the venue drop-down uses that cell followed by the spill operator #, written as a name called VenueList, so new venues appear in alphabetical order without anyone touching the validation.
Worked problem
Dependent drop-downs
The coordinators choose a venue type (Hall, Garden or Waterfront) in column C, and column D should then list only venues of that type. The venues are in a table called Venues with columns Name and Type. How does Dagny build the second drop-down?
Show solution
- On the Lists sheet, spill one sorted list per type, for example =SORT(FILTER(Venues[Name],Venues[Type]="Garden")) in G2, with similar formulas for Hall and Waterfront.
- In Name Manager, create the names Hall, Garden and Waterfront, each referring to its spilled list with the # operator after the list's first cell on the Lists sheet.
- Select D5:D200 on the Input sheet with D5 active, choose Data Validation > Allow List and enter the source =INDIRECT($C5).
- Test a row with Garden and confirm only garden venues appear.
Answer: INDIRECT turns the type chosen in each row into the name of a list, and the spilled formulas keep every list current. The relative $C5 makes each row depend on its own venue type.
Two details trip people up with list validation. The In-cell dropdown check box must be ticked or there is no arrow, although the restriction still applies. And list validation is case-insensitive when matching what someone types, so "gg" is accepted for "GG"; if case matters, add a Custom rule using EXACT instead.
Custom formulas
Custom validation accepts any formula that returns TRUE for an entry you want to allow. As with conditional formatting, the formula is written for the active cell of the selection and adjusts for the others. Dagny used three custom rules on the input sheet.
=COUNTIF($A$5:$A$600,A5)=1
=AND(LEN(A5)=11,LEFT(A5,2)=E5,MID(A5,3,6)="-"&YEAR(D5)&"-")
=E5<>""The first rule rejects a booking code that already appears in the column. The second checks the code's structure against the row's package and event date. The third, applied to columns F to J, refuses any entry in a row until the package code in column E is filled, which forces coordinators to start with the most important field. Custom rules can reference other cells in the row freely, which built-in types cannot.
Input messages and error alerts
The Input Message tab shows a small note, with an optional bold title, whenever the cell is selected. It is the gentlest form of guidance and works even with Allow set to Any value. Dagny's guest count cell says "Guests: total expected, including the couple. Whole number from 2 to 400."
The Error Alert tab sets the response to an invalid entry. There are three styles, and the difference between them is a common exam question.
| Style | Icon | What the user can do |
|---|---|---|
| Stop | Red circle | Retry or Cancel; the entry is never accepted |
| Warning | Yellow triangle | Yes keeps the entry, No edits it, Cancel removes it |
| Information | Blue i | OK keeps the entry, Cancel removes it |
Only Stop actually prevents invalid data. The other two styles let the user override, which is right for soft limits. Guest counts above 400 are rare but possible for a festival, so Dagny gave that rule the Warning style with the message "Over 400 guests needs Rosalind's approval. Keep this number?" The booking code rule uses Stop. Clearing Show error alert after invalid data is entered turns the alert off completely, leaving only the input message.
Dates, times and decimals in practice
Date and time rules look simple but hide two traps. The first is that Excel stores dates as serial numbers and times as fractions of a day, so a time rule "between 9:00 and 20:00" is really between 0.375 and 0.8333. You can type the limits as times in the dialog and Excel converts them. The second is that a cell containing both a date and a time, such as a ceremony start entered as "June 12, 2027 3:30 PM", will fail a pure time rule because its value is more than 1. Dagny kept the event date and the ceremony start in separate columns for exactly that reason.
Decimal rules suit shares and rates. The deposit share column allows a decimal between 0 and 1, and its input message reminds coordinators to type 0.5 for half, not 50. The cell is formatted as a percentage, which helps: typing 50 into a percentage-formatted cell with the default setting Enable automatic percent entry stores 0.5 and passes the rule. Whole number rules reject any fraction, so a guest count of 120.5 is refused even though it falls between the limits.
Limits can be formulas that refer to other cells, which keeps rules connected to the business. The deposit due date allows a date between the booking date in column B and the event date in column D, written as =$B5 and =$D5 in the Start date and End date boxes. A tasting appointment, held in column K, must fall at least 30 days before the event, so its rule allows a date less than or equal to =$D5-30. Rules like these are easier to maintain than custom formulas, because anyone opening the dialog can read them.
| Column | Allow | Settings | Alert style |
|---|---|---|---|
| Booking date | Date | less than or equal to =TODAY() | Stop |
| Event date | Date | between =TODAY() and =DATE(2028,12,31) | Stop |
| Guests | Whole number | between 2 and 400 | Warning |
| Deposit share | Decimal | between 0 and 1 | Stop |
| Tasting date | Date | less than or equal to =$D5-30 | Information |
| Package | List | =PackageCodes | Stop |
Designing an input sheet
Validation works best as part of a deliberate layout. Dagny's input sheet followed four rules that came from watching the coordinators use the old one. Input columns are on the left, in the order people think about a booking, and formula columns are on the right, shaded grey and locked. Every input column has an input message, because new staff will not read a separate instruction sheet. Lists live on a hidden, structure-protected sheet so nobody deletes a venue by accident. And the data sits in an Excel table, so validation, conditional formatting and formulas all extend automatically to new rows.
That last point matters more than it seems. When a table grows by one row, Excel copies the validation from the row above into the new row. When a plain range grows, new rows have no validation unless you extend the rule by hand, and an unvalidated row looks exactly like a validated one until something goes wrong.
What validation does not catch
Validation checks typed entries. It does not check values that arrive by pasting, by Fill, or by formulas, and it does not re-check data that was there before the rule was created. Pasting a value over a validated cell can even replace the validation itself. To find invalid entries already in the sheet, use Data Validation > Circle Invalid Data, which draws red circles around every cell that breaks its rule; Clear Validation Circles removes them. Dagny ran Circle Invalid Data on the existing 430 bookings and found eleven package codes typed in lower case and two guest counts of zero.
Because pasting bypasses validation, she protected the sheet (lesson 1) so that only the input columns were unlocked, and told the coordinators to use Paste Special > Values when copying from email. Protection does not stop pasting into unlocked cells, but it keeps the formulas and lists safe.
Finding and copying validation
Home > Find & Select > Data Validation selects every cell on the sheet that has a validation rule, which is useful in an unfamiliar workbook. Go To Special (F5, then Special) offers Data validation: All or Same for the same purpose. To copy a rule to new cells without copying their contents or formats, copy a validated cell and use Paste Special > Validation. To remove rules, select the cells and choose Data Validation > Clear All.
Worked problem
Auditing an inherited input sheet
The coordinators' old sheet from 2025 has validation somewhere, but nobody remembers where or what. Dagny wants to see every rule and mark the entries that break them. What does she do?
Show solution
- Press F5, choose Special, then Data validation and All to select every validated cell.
- Open Data Validation for each selected area to read its settings.
- Choose Data Validation > Circle Invalid Data to mark existing entries that break the rules.
- Fix or delete the circled entries, then choose Clear Validation Circles.
Answer: Go To Special finds the rules and Circle Invalid Data finds the data that already breaks them.
Common mistakes
MistakeTyping Packages[Code] in the List source box.
InsteadUse a name that refers to the table column, or INDIRECT("Packages[Code]").
MistakeUsing the Warning alert style and expecting invalid entries to be blocked.
InsteadOnly the Stop style prevents an invalid entry.
MistakeAssuming validation checks pasted values and existing data.
InsteadUse Circle Invalid Data, and paste values only into validated cells.
MistakeWriting a custom rule for the wrong cell of the selection.
InsteadWrite it for the active cell and anchor references as you would in a copied formula.
MistakeForgetting Ignore blank when cells may be left empty.
InsteadTick Ignore blank, or test for blanks inside a custom formula.
Summary and key terms
- Data validation restricts entries by type: whole number, decimal, list, date, time, text length or custom formula.
- List sources can be typed, ranges, names pointing at table columns, or array formulas and spilled ranges.
- Custom formulas are written for the active cell and can test other cells in the row.
- Input messages guide; error alerts respond, and only Stop blocks invalid entries.
- Circle Invalid Data finds existing problems, because validation checks only typed entries.
- Data validation
- Rules that limit what can be entered in cells.
- List validation
- A rule that accepts only entries from a source list and can show a drop-down.
- Input message
- A note shown when a validated cell is selected.
- Error alert
- The response to an invalid entry: Stop, Warning, or Information.
- Circle Invalid Data
- A command that marks existing cells breaking their validation rules.
- Dependent drop-down
- A list whose choices depend on another cell's value.
Practice problems
Work each problem on paper first, then reveal the answer to check.
Which error alert style always rejects an invalid entry?
Show answer
Stop.
How do you make a drop-down grow when rows are added to a table?
Show answer
Use a name that refers to the table column as the list source.
Which command marks existing entries that break validation?
Show answer
Data Validation > Circle Invalid Data.
Which Paste Special option copies only validation rules?
Show answer
Validation.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.