Quick answer: Excel conditional formatting highlights cells or rows when a formula returns TRUE, while data validation restricts or warns about what users may enter. You can use logical formulas such as AND, OR, ISNUMBER and COUNTIF to build both. For example, highlight a row if sales are at least 2,000 and attendance is below 90%, then prevent attendance entries outside 0%–100%. The same business rule can power a warning, a validation check and a report, but these are different layers of protection.
This is a practical guide for making an Excel input sheet more trustworthy. It extends our logical-formula tutorial into visible, user-facing spreadsheet behavior, including five original rules and a testing checklist.

Conditional formatting vs data validation
| Question | Conditional formatting | Data validation |
|---|---|---|
| What does it do? | Changes a cell’s appearance when its rule is TRUE | Checks entries against a rule and may reject invalid input |
| Where? | Home → Conditional Formatting → New Rule | Data → Data Validation |
| Formula requirement | Typically TRUE/FALSE for formula-based rules | Custom rules use TRUE/FALSE |
| Typical example | Color rows when attendance falls below 90% | Allow attendance only between 0% and 100% |
| Can it fix bad data? | No. It only signals a condition visually | It can block new invalid entries, but does not clean all existing data |
| Best companion | Audit/status column | Data-quality review and protective worksheet design |
The sample learning sheet
Create a table with headings in row 1: A = Name, B = Department, C = Sales, D = Attendance and E = Years. Enter at least five fictional employees. Example values: Maya / Sales / 3,800 / 96% / 3; Jamal / Support / 2,450 / 91% / 7; Aisha / Sales / 1,850 / 93% / 2; Noah / Marketing / 3,175 / 89% / 5; Lina / Sales / 2,000 / 90% / 1.
Format column D as Percentage before entering attendance. Be careful: typing 90 into a cell formatted as a percentage can mean 9,000%, whereas typing 90% produces the decimal value 0.9.
1. Highlight a whole row when a target is achieved
Select A2:E20. Choose Home → Conditional Formatting → New Rule → Use a formula to determine which cells to format. Enter:
=AND($C2>=2000,$D2>=90%)
Pick a subtle green fill and save. The dollar signs lock the columns C and D while the row number changes as the rule is applied to each row. If you wrote $C$2, all rows would check the same row 2 values. In our data, Maya, Jamal and Lina should be highlighted under this rule.
2. Highlight rows needing attendance review
Add a second rule to the same range using =$D2<90%. Choose a light red fill. Noah should be flagged. If the rules overlap, decide which one takes precedence and review Manage Rules. The goal is readable status, not a colorful dashboard full of conflicting signals.
3. Flag missing or invalid department values
Use conditional formatting to highlight a missing department in column B:
=OR($B2="",$B2="Unknown")
This works as an attention flag but cannot prevent someone from typing “Financ” rather than “Finance”. For controlled input, create a small list of valid departments and apply a Data Validation dropdown. A dropdown is often simpler to maintain than a lengthy OR expression.
4. Restrict Attendance to 0%–100%
Select D2:D20, starting with D2 as the active cell. Go to Data → Data Validation → Allow: Custom, then use:
=AND(ISNUMBER(D2),D2>=0,D2<=1)
Because Excel stores 90% as 0.9, the maximum allowed value is 1, not 100. On the Error Alert tab, choose a clear instruction, such as “Enter a percentage from 0% to 100%.” Be explicit about whether blanks are allowed. If you expect blanks while collecting data, choose an appropriate Ignore blank setting and test it.
5. Prevent duplicate employee IDs
If column F contains unique Staff IDs, select F2:F20, choose Data Validation → Custom and use:
=OR(F2="",COUNTIF($F$2:$F$20,F2)=1)
This permits blank entries while warning about repeated IDs. It is useful for training, but Excel validation is not a database uniqueness constraint. Existing imported duplicates may not be highlighted automatically, and workflows such as paste or importing can have different validation behavior. Add a visible check column as well:
=IF(F2="","ID missing",IF(COUNTIF($F$2:$F$20,F2)>1,"Duplicate ID","OK"))
6. Make a combined quality-check column
In G2, create a practical indicator that catches invalid attendance, negative sales, missing department and duplicated IDs, rather than relying on colors alone:
=IF(OR(NOT(ISNUMBER(D2)),D2<0,D2>1,NOT(ISNUMBER(C2)),C2<0,B2="",F2="",COUNTIF($F$2:$F$20,F2)>1),"Review inputs","OK")
This status is especially useful when your sheet is shared, printed or exported, because conditional formatting can be overlooked. As with all formulas, test empty cells, text pasted into numeric columns and correct values before relying on a single quality flag.
Seven scenarios to test before sharing the sheet
| Input scenario | Expected behavior | What it tests |
|---|---|---|
| Sales 2,000; Attendance 90% | Meets highlight rule | Equality at both thresholds |
| Sales 1,999; Attendance 95% | No target highlight | Below sales threshold |
| Sales 3,000; Attendance 89% | Attendance review highlight | Fails attendance condition |
| Attendance 110% | Validation error / quality review | Upper limit |
| Attendance typed as text | Quality review | Numeric data type |
| Repeated Staff ID | Duplicate review | COUNTIF uniqueness check |
| Blank Department | Department warning | Missing data |
What these rules do not guarantee
- Conditional formatting visually signals a rule. It does not prevent an invalid value being stored.
- Data validation helps protect manual entry, but existing data and some paste/import operations require separate auditing. Microsoft’s guidance explains how to circle existing invalid data.
- Do not mix percentages and whole-number rates in the same field.
- Do not mistake visual coloring for a full audit trail. Keep a clear status column and review exceptions.
- Verify how rules behave in Excel for the web, Mac and Windows when sharing templates across teams.
Practical exercises
Use the five fictional staff above to build an editable training sheet. First apply the two formatting rules. Then set attendance validation and an ID uniqueness rule. Finally, enter each of the seven test cases and record whether the alert, highlight and status formula agree. If you want to turn this into a compensation exercise, use the companion Course Centrals HR Bonus Calculator draft and its verified sample workbook after attaching the downloadable file.
Frequently asked questions
Why is my whole row highlighted when only one cell should be?
The rule applies to the selected range. Check the Applies to range, use mixed references such as $C2 when a column should remain fixed, and avoid freezing the row accidentally.
Can a formula-based data validation rule reference another cell?
Yes. Custom rules can use cell references and formulas. Take care with relative references and the first active cell of the selection.
Does data validation automatically fix existing invalid entries?
No. Excel can apply validation to cells with existing values without necessarily alerting on all invalid existing values. Use Data Validation’s Circle Invalid Data or an independent check formula.
Can these rules work with AND or OR?
Yes. A conditional formatting formula such as =AND($C2>=2000,$D2>=90%) returns TRUE/FALSE and controls a visual rule; the same logical structure can be reused in custom validation.
Related Course Centrals guides and official references
Continue with IF and logical conditions, COUNTIFS for multiple-criteria counts and the Excel formula library.
Last verified: 14 November 2026. Official Microsoft documentation: Conditional formatting, Data validation, and IF with AND/OR/NOT. All practice data and examples are original.
