Module 2
Module 2
B. INTRODUCTION
The module explains how to do Data Validation in Excel: create
a validation rule for numbers, dates or text values, make data validation
lists, copy data validation to other cells, find invalid entries, fix and
remove data validation.
C. LEARNING CONTENT
VALIDATING THE DATA
Data validation is a feature in Excel used to control what a user
can enter into a cell. For example, you could use data validation to
make sure a value is a number between 1 and 6, make sure a date
occurs in the next 30 days, or make sure a text entry is less than 25
characters.
Data validation can also stop invalid user input. For example, if a
product code fails validation, you can display a message like this:
♦ Whole Number - only whole numbers are allowed. Once the whole
number option is selected, other options become available to further limit
input. For example, you can require a whole number between 1 and 10.
♦ Decimal - works like the whole number option, but allows decimal
values. For example, with the Decimal option configured to allow values
between 0 and 3, values like .5, 2.5, and 3.1 are all allowed.
♦ List - only values from a predefined list are allowed. The values are
presented to the user as a dropdown menu control. Allowed values can
be hardcoded directly into the Settings tab, or specified as a range on
the worksheet.
♦ Date - only dates are allowed. For example, you can require a date
between January 1, 2018 and December 31 2021, or a date after June 1,
2018.
♦ Time - only times are allowed. For example, you can require a time
between 9:00 AM and 5:00 PM, or only allow times after 12:00 PM.
♦ Text length - validates input based on number of characters or digits.
For example, you could require code that contains 5 digits.
2. Apply these changes to other cells with the same settings - this
setting will update validation applied to other cells when it matches the
(original) validation of the cell(s) being edited.
When applied to a cell in the worksheet, the dropdown menu works like
this:
Another way to supply values to a dropdown menu is to use a
worksheet reference. For example, with sizes (i.e. small, medium, etc.) in the
range F3:F6, you can supply this range directly inside the data validation
settings window:
You can also use named ranges to specify values. For example,
with the named range called "sizes" for F3:F7, you can enter the name
directly in the window, starting with an equal sign:
Once you get the dummy formula working like you want, simply copy
and paste it into the data validation formula area.
Data Validation Formula Examples
To allow only 5 character values that begin with "z" you could use:
AND(LEFT(A1)="z",LEN(A1)=5
This formula returns TRUE only when a code is 5 digits long and starts
with "z". The two circled values return FALSE with this formula.
To allow only a date within 30 days of today:
=AND(A1>TODAY(),A1<=(TODAY()+30))
=COUNTIF(range,A1)<2
=ISUMBER(FIND("@",A1)
For example, the screen below shows values circled that fail validation
with this custom formula:
Find cells with data validation
To find cells with data validation applied, you an use the Go To >
Special dialog. Type the keyboard shortcut Control + G, then click the Special
button.
When the Dialog appears, select
"Data Validation":
Note: you can use the keyboard shortcut Control + Alt + V to invoke Paste
Special without the mouse.
Clear all Data Validation
To clear all data validation from a range of cells, make the selection,
then click the Data Validation button on the Data tab of the ribbon. Then click
the "Clear All" button: