2.3 Data Validation
1. Describe the allowed input before someone starts typing
A college events team needs to book food trays from a shortlist of suppliers. Picture a volunteer placing an order through a familiar delivery app such as Swiggy, then keeping the club's own approval log. The log should accept at most twelve trays per request. Somebody sees a new cell and types twenty. Another enters 1.5 after asking for half a tray, but the supplier only accepts full units in this fictional example. The coordinator wants to spot those problems before reading the order over the phone.
Data Validation is the rule Excel attaches to one or more cells to guide direct entry. It can inspect a value and offer a message that describes the expected input. The rule must come from something the person ordering actually needs. If your supplier accepts half a tray, asking Excel to block fractional values creates a problem instead of solving one. Write the rule in words first and include the purpose so a future editor knows when to change it.
Validate down to examples. Decide what should pass, what should produce a message and how you will check old or pasted records. A good test includes the boundary that separates a valid entry from an invalid one.
Write the field rule as an acceptance example
- Field. Quantity per pickup request, measured in whole trays. This rule belongs to that column, while the adjacent cost field can contain decimal currency.
- Allowed. Numeric values 1 through 12 inclusive. The entries 1 and 12 test the two endpoints, while 5 is an ordinary observation.
- Rejected. Zero, 13, fractional units and a label such as two. Each tests a different type of mistake.
- Blank policy. A request row may be empty while someone prepares it. Once submitted, every row with an ID needs a quantity. Put that rule in an audit too, because an empty cell that has never been edited may not trigger a validation prompt.
- Owner. The supplier or coordinator confirms the quantity policy. A workbook editor should not move the limit without confirming the process.
Be specific about the quantity's unit and scope. A limit of twelve per request is a rule for one number. A rule such as twelve trays per club per week relies on a group total across multiple rows and often on trusted, current data. A direct check in one input can still be helpful, and the system that approves the weekly limit needs its own verification. A cell rule does not enforce rules in the vendor's order system.
Pick the alert that matches the action
An Input Message can appear when the person selects the cell. Write it before they need to guess. Enter 1–12 whole trays for this request. is specific and short. An Error Alert can appear after they try an invalid direct entry. For a strict rule, use a Stop alert, select the option to show the error alert, and give a short instruction such as Enter a whole number from 1 to 12. Split permitted larger quantities into separate requests. The split only belongs there if your purchasing process actually permits it.
- Stop. Invalid direct entries prompt the user to retry or cancel. Use it when the listed conditions must hold for routine direct input.
- Warning. The dialogue can allow the person to keep the invalid entry. Use it when there is an accountable override and the report can still identify that row later.
- Information. The message advises and can allow the entry through. Some interfaces label it differently. Use it if the sheet's purpose is guidance and you accept that exceptional data may remain.
Running a rule with a message you can read is more informative than silently turning a bad input red. Rewrite a message that says only Wrong. The person needs to know which field and range were expected, what action to take, and when to ask the owner. A second reader should be able to perform the correction from the message alone for routine typing errors.
2. Match the validation type to a field's actual meaning
Select a built-in option for a simple condition
| Validation type | Practice use | Boundary or contrast |
|---|---|---|
| Whole number | Count trays, 1 to 12 | 1 and 12 pass; 0 and 1.5 fail |
| Decimal | Approved discount rate from 0 to 0.25 | 0.25 is 25%; 25 is twenty-five whole units |
| Date | Collection days from 16 to 20 November 2026 | 20 November is included by Between; 21 November is out |
| Time | Same-day collection between 09:00 and 17:00 | 17:00 is on the boundary; 17:01 is beyond it |
| Text length | At most twenty characters in a brief note | Length alone does not prove that the note is meaningful |
| List | Approved Requested, Ready and Received status choices | Use a drop-down source and test an unlisted direct input |
| Custom | Issued tag format and uniqueness within a specific block | A correctly shaped duplicate can still fail |
Each of these choices is a different interpretation of the cell. A rate can use Decimal with a maximum of 0.25, then a Percentage format so users see 25%. Format two samples and compare their stored decimal meanings. If a user types 25 into a cell in General and later applies Percentage, the display is 2500%. Enter 25% deliberately or verify the actual fractional input. Avoid setting the upper bound to 25 when you meant one quarter.
A date rule checks numeric Excel date values. Use a DATE formula in the boundary fields so the year, month and day order is unambiguous. Check a known date inside, one at each edge and one just outside. Use a date display with a visible month name. Avoid assuming a pasted text date will be interpreted the same way on another machine. A business rule for dates and times should say whether a time component is allowed. If you need the whole last day for timestamps, check for values before midnight of the next day rather than treating the end-day midnight serial as the entire last day.
Excel times are fractions of a day. TIME can express a start and an end without relying on an ambiguous 12-hour entry. A daytime Between rule with 09:00 and 17:00 has a clear ordering. If a collection desk opens at 22:00 and stops at 02:00 the following morning, the interval crosses the day boundary. Use complete dates and times or an explicit time-of-day rule that treats after 22:00 or before 02:00 as the allowed band. Explain which boundary values count. Ordinary Between is meant for a lower and upper bound in their normal order.
Treat text length as a narrow check
Six characters can be six digits, six letters or a mixture. A text-length rule with a target of 6 accepts anything of that length unless other logic applies. If you want only a six-digit postal label, protect the original code as text before entry and make an explicit digit-shape rule. A value might look like six digits because of formatting even when its input is numeric. The rule should check what the receiving system needs, not what the display happens to show.
Excel's LEN counts spaces as part of a string. An editor who accidentally adds ordinary trailing spaces may get a length failure without noticing the characters on screen. Show the expected length and an example, and keep the original if you need to inspect a pasted value. For free-form notes, avoid a tight length limit unless the receiving field actually requires it. A person typing a name with several parts may need the extra room.
3. Audit what direct entry could not prevent
Someone can paste from a spreadsheet whose layout differs from yours. Existing invalid values can also remain after you add a rule to the destination. Excel's direct error message is designed for typing into a cell. Microsoft documents paths such as copying, filling, calculated results and macro writes that do not behave the same way. Treat the current workbook data as something to verify before using it in a report.
Some paste modes can replace the destination's cell metadata, including validation. Paste Values can avoid carrying the source rule, so it is useful for keeping the destination's existing rules. It does not promise that invalid pasted data will be stopped. The correct follow-up is to inspect a test cell's rule and check the pasted value independently. A thick yellow border or a dropdown arrow is not a certificate that the stored data qualifies.
Check the right evidence after a paste
- In a duplicate sheet, try one direct input you expect to fail. Read the actual message and check whether the prior valid value remains if you cancel.
- Check the rule still belongs to the cell you intended after a copy, fill or paste. Inspect Data Validation on one changed cell and one untouched cell.
- Use Circle Invalid Data where supported in desktop Excel, or run helper checks on the imported rows. Invalid-data circles rely on the validation criteria still present on those cells.
- For a row with an ID and a blank required field, review the blank on purpose. The absence of an alert is normal when nobody typed a value. A helper check gives you a filter to find those draft rows.
- If the accepted values came from other cells, modify one source criterion in a copy and verify old stored inputs. Changing the rule or its source does not repair existing cell values.
Recall. You set a Stop alert and received no warnings when you pasted a column. What two different facts would you verify before handing over the sheet? Pick one check for the validation setting and a separate check for the records.
Plan for older and browser-based workbooks
Find Data Validation on the Data tab in the available edition. Current Microsoft documentation covers core validation functionality for Microsoft 365, desktop releases and Excel for the web. The complete menu, managed options and audit commands can vary by platform and file state. The examples use desktop Excel where the full dialogue and Circle Invalid Data are available. If you edit in the browser, check the available validation type and carry out the same helper-column tests. A sheet or workbook with protection or certain sharing settings can restrict editing rules. Coordinate that access with its owner.
4. Lab. Practice a strict tray limit and a separately checked rate
Goal. Build two clear entry rules and an independent audit. Use a blank practice sheet. Put Request ID, Trays and Discount rate in A1:C1. Type the numbers as numbers with your edition's decimal separator. The distinctive errors are deliberate. Add validation after entering the first four records so you can see what happens to pre-existing data.
| Request ID | Trays | Discount rate |
|---|---|---|
| F-01 | 1 | 0 |
| F-02 | 12 | 0.25 |
| F-03 | 13 | 0.2 |
| F-04 | 1.5 | 0.26 |
Implement the rule, then test the stored data
Start with the quantity range
Select B2:B6. Under Data Validation, choose Whole number and Between. Set the minimum to 1 and maximum to 12. Add an input message stating the unit and set a Stop alert. Record which endpoints are included. Row 6 is blank so you can test a fresh entry without replacing one of the supplied records.
Test one allowable and two invalid entries
Try typing 12 in B6. It should be allowed. Try 13 and cancel when Stop appears. Then try 1.5. Stop should also ask for a valid value under Whole number. Clear the successful value from the scratch row when done. The test says what a direct edit experiences, and you will check completeness separately.
Set the percent rule using its stored unit
Select C2:C6. Use Decimal, Between, minimum 0 and maximum 0.25 with Stop. Apply a Percentage display to the range. C3 should read 25% and C5 should read 26%, even though the second value was there before validation and falls outside the allowed rate. Try typing 25% and 26% in C6 to check the boundary for new direct entry. Restore the scratch row after testing.
Compare desktop circles to the helper
Where available, use Circle Invalid Data on the working sheet. Look for B4, B5 and C5. Use the helper formulas below even if the circle command is absent. A visible circle draws attention, while a helper with FALSE can support filtering, counting or reviewing the exact failures.
In D1 type Trays OK? and in E1 type Rate OK?. Enter the formulas below in row 2 and fill through row 5. The first test checks that the number lies in range and that dividing it by 1 leaves no fractional remainder. The formula checks number type before doing the numeric work. The second makes sure the rate is numeric and belongs between 0 and one-quarter.
D2 =IF(ISNUMBER(B2),AND(B2>=1,B2<=12,MOD(B2,1)=0),FALSE)
E2 =IF(ISNUMBER(C2),AND(C2>=0,C2<=0.25),FALSE)
The expected pairs for D and E are TRUE and TRUE on row 2, TRUE and TRUE on row 3, FALSE and TRUE on row 4, and FALSE and FALSE on row 5. Try a numeric value stored as text using an apostrophe in a spare copy. It may look identical in the table and ISNUMBER should still return FALSE. If a request is allowed to remain in draft, check the quantity only once its ID or status says it reached the required step. A blank auditable result is a workflow decision.
Extend the same idea to a collection deadline
In a spare sheet add a column named Collection day. Set Date, Between, and use =DATE(2026,11,16) and =DATE(2026,11,20) as the boundaries where the dialogue supports date formulas. Set a calendar display. Type a date your locale recognises for 20 November and then one for 21 November. Under Stop, the end date should pass and the following date should produce the configured message. A formula returning a date or a pasted value needs a separate audit even if it looks like the same serial.
For a practical audit, retain start and end dates in labelled cells H2 and H3, then check known stored calendar values with =IF(ISNUMBER(F2),AND(F2>=$H$2,F2<$H$3+1),FALSE) for a timestamp-inclusive range. With the usual integer date serials and fractional times, any time on 20 November belongs before midnight on the 21st. If the source must contain date-only values, separately check that the serial has no fractional part. A status of true here establishes that the serial meets the chosen range, not the source timestamp's timezone or authenticity.
If another editor moves the deadline from Friday to Thursday, check a Friday row that already exists. A changed boundary does not necessarily prompt you about that row. The helper can recalculate and flag it. Confirm whether the booking was already approved under the old rule before you repair, retain or cancel it. A validation change alone does not tell you which historical policy was in force.
5. Use a Custom formula when one value has several conditions
A different campus logistics team labels equipment as event stock or workshop kits. The fields use either EVT- or KIT- followed by four digits, such as EVT-0012. These codes are made up. The team wants each code to appear once in a defined list. Checking the first three letters catches a few typos. It would still allow EVTwrong, an extra suffix or a duplicate. Check all conditions in a single validation formula so that the later rule does not replace an earlier one on the same cells.
Design the true and false cases before applying the Custom rule
A formula entered under Allow > Custom should return TRUE for an allowed entry. A result of FALSE means it fails when the rule runs. The practice shape test compares the typed prefix exactly, checks length and compares the four-character suffix to its numeric value formatted back to four digit places. For example, 0012 converts to 12 and displays as 0012 under the fixed format. A suffix of 12.0 may convert to the same number in a decimal-point locale, but its characters do not match 0012. The equality check catches the difference.
Use IFERROR to return FALSE when converting a suffix such as 00A1 cannot produce a valid number. EXACT checks letter case. LEN checks the full string length, including ordinary extra spaces. These checks are designed for the exercise's uppercase Latin prefixes, displayed digit convention and English function names. Test the typed examples in your own edition and locale if you reuse the formula for an operating workbook. A code of the right shape still needs to correspond to an issued item.
COUNTIF looks at the scope of the duplicate rule. In the sample, the entire target range is $A$2:$A$9 and the current entry is initially A2. The dollar signs keep the checked block fixed while the relative A2 moves to A3, A4 and later rows. There should be exactly one matching value including the current proposed entry. Excel's normal COUNTIF text matching can ignore letter case and interpret wildcards. The shape check disallows wildcard characters in this example. It also restricts the case allowed into the validated list. If a workbook uses arbitrary literal labels as criteria, design the comparison to account for wildcard characters explicitly.
Run a simple formula in a helper first when troubleshooting. If you temporarily evaluate the uniqueness formula on an empty sheet before the code is present, it cannot prove an unentered request is unique. Put a test code in a copy to check how a stored value behaves. Then test direct Data Validation acceptance separately in the actual range. Microsoft documents the unique-values pattern using a relative current cell and an absolute comparison range.
6. Lab. Check a tag's shape and whether it already exists
Goal. Practice a code stricter than a prefix-only rule. On a new sheet place Equipment ID in A1, Shape OK? in B1 and Audit in C1. Use A2:A9 to make the reference bounds easy to verify. Set A2:A9 to Text before entry if desired. Leave the entire range blank for the direct entry test. Keep an unvalidated practice copy of the sheet for the imported-audit exercise.
| Input | Shape | Direct entry outcome under Stop |
|---|---|---|
| EVT-0012 | Pass | Accept if this is its first occurrence |
| KIT-0099 | Pass | Accept if this is its first occurrence |
| EVT-0012 | Pass | Reject a second copy while the first remains in the block |
| evt-0012 | Fail | Reject the lowercase prefix |
| KIT-009 | Fail | Reject the short suffix |
| EVT-00A1 | Fail | Reject the letter inside the suffix |
| OTHER-88 | Fail | Reject the unrecognised prefix |
- Check the shape expression. Use the first formula in B2 and adjust the row by filling it through B9. In the unvalidated copy, enter the seven sample codes in A2:A8 in the shown order. B2:B4 should hold TRUE, then B5:B8 should each hold FALSE. Blank A9 fails the shape check, so the audit will label it separately.
- Set the combined validation. On the clean copy select A2:A9 beginning with A2. Open Data Validation > Custom and enter the second formula as one line. Use a Stop style with a message such as Enter a unique EVT- or KIT- code with four digits. Ensure the alert is enabled. Test the actual range on your edition. If setting a relative custom rule across a range is awkward, Microsoft's example sets the rule in the first cell and copies it to the remaining cells; keep the quantity of copied metadata under control. Verify the resulting rule refers to the correct current row.
- Try valid and invalid direct entries. Enter EVT-0012 into A2 and KIT-0099 into A3. Try EVT-0012 in A4. It should be rejected because another row already contains that exact code. Try EVT-00A1 and a different unique code such as KIT-0100. Keep a record of how the message and resulting contents differ.
- Run the audit against copied data. In the unvalidated copy containing the seven sample rows, put the third formula in C2 and fill through C9. Rows 2 and 4 say Duplicate ID. Row 3 says OK. Rows 5 through 8 say Review ID. Row 9 says Missing. The audit assumes every row in this small reserved list deserves a check; on a larger sheet use a separate field to mark rows that are in scope and should be complete.
- Investigate before fixing the duplicate. Do not assume which of A2 or A4 is wrong. Read the source tickets and confirm which code belongs to each record. In the practice copy, replace the second EVT-0012 with EVT-0013 and check that A4 becomes OK. Read the audit for A2 too. A nearby lowercase variant still needs review because the comparison ignores case. A helper on the entire block recalculates its comparison from the new data.
B2 shape check
=IFERROR(AND(OR(EXACT(LEFT(A2,4),"EVT-"),EXACT(LEFT(A2,4),"KIT-")),LEN(A2)=8,EXACT(RIGHT(A2,4),TEXT(VALUE(RIGHT(A2,4)),"0000"))),FALSE)
Custom validation source
=IFERROR(AND(OR(EXACT(LEFT(A2,4),"EVT-"),EXACT(LEFT(A2,4),"KIT-")),LEN(A2)=8,EXACT(RIGHT(A2,4),TEXT(VALUE(RIGHT(A2,4)),"0000")),COUNTIF($A$2:$A$9,A2)=1),FALSE)
C2 audit
=IF(A2="","Missing",IF(NOT(B2),"Review ID",IF(COUNTIF($A$2:$A$9,A2)=1,"OK","Duplicate ID")))
COUNTIF compares case insensitively. In the unvalidated practice copy the lowercase evt-0012 also counts toward the duplicates for the valid uppercase code. Its own audit still says Review ID because the shape check takes priority. After correcting the duplicate A4 to EVT-0013, the original A2 can still show Duplicate ID until the malformed A5 record is reviewed and assigned its own confirmed ID. That behavior is useful here because a case difference may hide the same intended item. Explain whether your real lookup system treats code case as significant before defining its duplicate policy.
A production workbook should scope the comparison so every record that must be unique is included. If you add A10 below this exercise, the original comparison range ends at A9. Expand it deliberately or use an appropriate table-wide check and test the next row. For IDs that must be globally unique across devices, imports or separate sheets, use the system controlling issuance to verify the identifier. The worksheet rule can help spot mistakes on this sheet.
7. Make a small hand-off ledger for the tests
Give your sheet owner a list of observed outcomes. Include one upcoming test date, the cells checked, and a note about the source policy. Tests should tell them what to do when they see a surprising value rather than only what menu you clicked. For example, after a copied data update they can look in B4 and C5 to verify the rule survived and separately check that no current row has a failed field. Those are evidence about the workbook they see today.
- Check the alert style. An enabled Warning message can accept an invalid input, which may be suitable for a documented override.
- Check the input type. A formatted rate can visually hide whether the source contained a valid decimal, a percentage or text.
- Check rule scope and required fields after adding a row. A blank field may have no stored entry that ever triggered the alert.
- Check dependent policy changes. If the maximum tray count became 10, the existing 12-tray request needs a review against its approval history.
- Check real authority. A well-formed code or valid date is possible without an actual source approval.
Separate a draft row from a submitted request
An intern opens a blank tracker and fills the request ID before the discount has been approved. At that moment a blank discount can be perfectly reasonable. If the same line is marked Submitted, the blank might be a problem. In the first lab you can add a Stage column in F and choose Draft or Submitted using a controlled list later. A helper in G2 could use =IF(F2="Submitted",IF(AND(D2,E2),"Ready to review","Check fields"),"Draft"). It reads the two validation audit results rather than assuming that the presence of an ID proves the row is complete.
Test it in the lab before editing any of the input values. Enter Submitted in F2 and F4, and Draft in F5. G2 should show Ready to review because both of that row's checks pass. G4 should show Check fields because its quantity is 13, even though its rate passes. G5 should show Draft while its underlying fields still need review. Those helper words support a filter. They do not grant payment approval or replace the supplier's confirmation.
If a real workflow has more stages, decide what an unexpected or missing stage should mean. This formula treats every other stage as Draft for the tiny input set. A production audit should return an explicit review label for an unrecognised state unless policy defines one. Write the states next to their source list. Your audit should distinguish a work-in-progress request waiting for information from a confirmed record that needs an owner to correct its fields.
Count your filters against the small example before running them on a long list. There are two original rows whose tray check fails, and only one of those also fails the rate check. The number of failed checks is three, while the number of distinct rows needing attention is two. An owner who plans one follow-up per request needs the second number. Keep a separate count for each field if those issues go to different owners.
Review validation after a protected template is reused
A teammate could copy last month's request sheet and start entering new lines with the old cap on trays. Confirm the new sheet's limits, date bounds and allowed data sources. If protection prevents a change, ask the workbook owner to adjust the rule in the intended template instead of bypassing the policy in a duplicate. Keep your initial tests in scratch data so that checking the sheet does not accidentally create a real purchase request.
Read what happened to the first new row and the first existing row that should now fail. If an existing rule incorrectly points to the previous sheet, correct the source reference and retest before allowing users to enter more records. When inputs change over time, label version dates in plain language. A downstream analyst who sees an apparently out-of-range older value can then determine which rule applied, rather than assuming an oversight.
When you think the worksheet is ready, tell someone else exactly which example they can type to verify it. A clear requirement, a test value and a predictable message make the workbook easier to trust than a screenshot of the Data Validation dialogue.
Continue practising at the existing Excel Task Hub. Before you enter a formula, pick one sample that should pass and one that should fail.
8. Interview questions with practical answers
How do you set a tray limit without changing historical records?
Choose Whole number, Between 1 and 12, on the intended quantity range. Configure and test the direct Stop rule. Use an independent helper or desktop invalid-data circles to flag historical values, and check them against the rule that applied when the record was approved.
Why can a pasted value survive a strict validation alert?
The direct typing message does not enforce every way data can enter. Check the current metadata after paste and run a separate audit of the values. Paste Values can protect the destination rule while still requiring the second check.
How do you make a code unique and require an exact shape?
Combine both conditions in the same Custom formula. Use an absolute range for the duplicate count, a relative current cell and an explicit shape expression. Test new and repeated correct-looking codes. Check the real source of IDs separately from the pattern.
Why doesn't a six-character check enforce an Indian PIN code?
Length measures characters. Six letters can meet it. Preserve the text of the input and use a specific digits check if the receiving workflow needs that shape. Check an issued postal code against an authoritative source if its actual validity matters.
How do you manage a deadline that changes after requests have been entered?
Use labelled numeric boundary inputs and audit each stored date against the current rule. Keep approval evidence for historical exceptions. Test one date on the boundary and one from before the policy change.
9. Predict the result before opening the answer
What alert style should force a volunteer to fix 13 trays before a normal direct entry can succeed?
Answer and reasoning
Stop, with the error alert enabled. Warning and Information can allow the entry to remain. Check existing and pasted values separately.
What stored decimal should represent the maximum of 25 percent?
Answer and reasoning
0.25, one quarter of a whole unit. A display can show 25% while the validation compares against 0.25.
If the time interval includes 17:00, what should a standard Between rule do at 17:01?
Answer and reasoning
Reject it under Stop if the end is 17:00. The later input has a larger fraction of the day. Check the stored time and actual interval if the result differs.
Why does EVT-0012 pass shape but still fail when someone enters it a second time?
Answer and reasoning
The full rule checks uniqueness too. The current value and the existing value count toward the same identifier, even though both match the format.
Can you rely on the Ignore blank option to prove all submitted rows are complete?
Answer and reasoning
No. Check completeness from the records. A person can leave a cell unedited, and different ways of removing or supplying data can behave differently. An audit can mark the missing required fields.
10. Six ideas to take to your next worksheet
- Write the field policy first
Describe the unit, allowed range and owner. That describes the business condition the workbook approximates.
- Messages have a job
Give the user a clear example before typing and explain how to correct the input when the alert appears.
- Test an exact boundary
Try the first and last valid entries plus one outside on a copy. Compare what happened to the contents afterward.
- Audit after copy or import
Inspect current validation and verify the stored fields independently. These checks answer different questions.
- Keep the count range fixed
In a custom duplicate rule, a locked range and a relative current entry make each row check the intended block.
- Check required facts
Even a well-shaped code or valid date can lack operational approval. Verify the source before using it to act.
Microsoft references
- Apply validation types and custom formula examples
- Alert styles, limitations and validation troubleshooting
- Check existing values with invalid-data circles
- Use DATE to create a known date serial
- Use TIME to create a time fraction
- Check exact case with EXACT
- Use LEN and account for spaces
- COUNTIF and conditional counts
- Paste Values and other copy options