ISO 9001:2015 Certified
Govt. of Karnataka Affiliated
ADV EXCEL CLASS NOTES

Data Validation in Excel

Data Validation is an Excel feature that controls what users can enter into a cell. It helps prevent incorrect data entry and ensures data accuracy.

Example: If a student’s marks should be between 0 and 100, Data Validation can stop users from entering 150 or -10.

Why Use Data Validation?

Benefit Description
Avoid Mistakes Prevents users from entering invalid data.
Improve Accuracy Ensures data follows specific rules.
Create Dropdown Lists Allows users to select values from a list.
Reduce Manual Errors Limits incorrect typing.

Location of Data Validation

Data Tab → Data Tools Group → Data Validation


Data Validation Dialog Box

When you click Data Validation, a dialog box appears with three tabs:

Tab Purpose
Settings Define validation rules.
Input Message Display instructions when a cell is selected.
Error Alert Show an error message for invalid entries.

Types of Data Validation

Validation Type Example
Whole Number Marks between 0 and 100
Decimal Percentage between 0 and 100
Date Only dates from current year
Time Office timing between 9 AM and 6 PM
Text Length Mobile number with fixed digits
List Dropdown for Gender, Course, City, etc.
Custom Validation using formulas

Example 1: Marks Between 0 and 100

Steps

  1. Select the Marks column.
  2. Go to Data → Data Validation.
  3. In Allow, select Whole Number.
  4. In Data, select Between.
  5. Minimum = 0
  6. Maximum = 100
  7. Click OK.

Now Excel allows only numbers from 0 to 100.


Example 2: Create a Dropdown List

Dropdown lists are the most commonly used Data Validation feature.

Example Course List

Course
Excel
Python
Tally
Power BI

Steps to Create Dropdown

  1. Select the target cells.
  2. Go to Data → Data Validation.
  3. Choose List in Allow.
  4. In Source, type:
    =Excel,Python,Tally,Power BI
  5. Click OK.

A dropdown arrow appears in the selected cells.


Example 3: Text Length Validation

Restrict a Mobile Number to exactly 10 digits.

Steps

  1. Select the Mobile Number column.
  2. Open Data Validation.
  3. Select Text Length.
  4. Choose Equal To.
  5. Enter 10.
  6. Click OK.

Excel accepts only 10-character entries.


Input Message

An Input Message appears when the user selects a validated cell.

Field Example
Title Enter Marks
Message Marks must be between 0 and 100.

Error Alert

Error Alert appears when a user enters invalid data.

Style Purpose
Stop Prevents invalid entry completely.
Warning Warns user but allows entry.
Information Shows information message only.

Remove Data Validation

  1. Select the validated cells.
  2. Open Data Validation.
  3. Click Clear All.
  4. Click OK.

Keyboard Shortcut

Shortcut Purpose
Alt + A + V + V Open Data Validation

 


Custom Formula to Restrict Duplicate Entries

Sometimes we want a value to be entered only once in a worksheet. For example:

  • Student ID should not be repeated.
  • Employee ID should be unique.
  • Mobile Number should not be duplicated.
  • Invoice Number should be entered only once.

In such cases, we can use Data Validation with a Custom Formula to prevent duplicate entries.


Example: Prevent Duplicate Student IDs

Student ID
1001
1002
1003

If a user tries to enter 1002 again, Excel should display an error message.


Custom Formula

=COUNTIF($A$2:$A$100,A2)=1

Formula Breakdown

Part Meaning
COUNTIF() Counts how many times a value appears.
$A$2:$A$100 Range where IDs are stored.
A2 Current cell value being checked.
=1 Allows the value only if it appears once.

Steps to Apply

  1. Select the cells (A2:A100).
  2. Go to Data → Data Validation.
  3. In Allow, select Custom.
  4. Enter the formula:
=COUNTIF($A$2:$A$100,A2)=1
  1. Click OK.

Now duplicate entries will not be allowed.


Real World Examples

Field Formula Example
Student ID =COUNTIF($A$2:$A$100,A2)=1
Mobile Number =COUNTIF($B$2:$B$100,B2)=1
Invoice Number =COUNTIF($C$2:$C$100,C2)=1
Employee ID =COUNTIF($D$2:$D$100,D2)=1

Error Alert Message

Setting Value
Style Stop
Title Duplicate Entry
Message This value already exists. Please enter a unique value.
Exam Tip: The most commonly used custom validation formula for preventing duplicates is:

=COUNTIF($A$2:$A$100,A2)=1