Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
8 views

Module 2

Uploaded by

Willy Ganaba
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Module 2

Uploaded by

Willy Ganaba
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

A.

TARGET LEARNING OUTCOMES


By the end of this lesson, the student should be able to:
Apply data validation settings to control data entry.
Identify and use database functions to perform calculations using
multiple database fields.

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 simply display a message to a user telling


them what is allowed as shown below:

Data validation can also stop invalid user input. For example, if a
product code fails validation, you can display a message like this:

In addition, data validation can be used to present the user with


a predefined choice in a dropdown menu:
This can be a convenient way to give a user exactly the values that
meet requirements.

Data Validation Controls


Data validation is implemented via rules defined in Excel's user
interface on the Data tab of the ribbon.

Defining Data Validation Rules


Data validation is defined in a window with 3 tabs: Settings, Input
Message, and Error Alert:

The settings tab is


where you enter validation
criteria. There are a
number of built-in
validation rules with
various options, or you
can select Custom, and
use your own formula to
validate input as seen:
The Input Message tab
defines a message to display
when a cell with validation rules
is selected. This Input Message
is completely optional. If no input
message is set, no message
appears when a user selects a
cell with data validation applied.
The input message has no effect
on what the user can enter — it
simply displays a message to let
the user know what is allowed or
expected.

The Error Alert Tab


controls how validation is
enforced. For example, when
style is set to "Stop", invalid data
triggers a window with a
message, and the input is not
allowed.

The user sees a message like this:

When style is set to Information or Warning, a different icon is


displayed with a custom message, but the user can ignore the message and
enter values that don't pass validation. The table below summarizes behavior
for each error alert option.
ALERT
STYLE BEHAVIOR
Stops users from entering invalid data in a cell. Users
Stop can retry, but must enter a value that passes data
validation. The Stop alert window has two options: Retry
and Cancel.
Warns users that data is invalid. The warning does
nothing to stop invalid data. The Warning alert window
Warning
has three options: Yes (to accept invalid data), No (to
edit invalid data) and Cancel (to remove the invalid
data).
Informs users that data is invalid. This message does
nothing to stop invalid data. The Information alert
Information
window has 2 options: OK to accept invalid data, and
Cancel to remove it.

Data Validation Options


When a data validation rule is created, there are eight options available
to validate user input:
♦ Any Value - no validation is performed. Note: if data validation was
previously applied with a set Input Message, the message will still
display when the cell is selected, even when Any Value is selected.

♦ 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.

♦ Custom - validates user input using a custom formula. In other words,


you can write your own formula to validate input. Custom formulas
greatly extend the options for data validation. For example, you could
use a formula to ensure a value is uppercase, a value contains "xyz", or
a date is a weekday in the next 45 days.

The Settings Tab also Includes Two Checkboxes:


1. Ignore blank - tells Excel to not validate cells that contain no value. In
practice, this setting seems to effect only the command "circle invalid
data". When enabled, blank cells are not circled even if they fail validation.

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.

Simple Drop Down Menu


You can provide a
dropdown menu of options by
hardcoding values into the
settings box, or selecting a
range on the worksheet. For
example, to restrict entries to
the actions "BUY", "HOLD", or
"SELL" you can enter these
values separated with commas
as seen below:

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:

Named ranges are automatically absolute, so they won't change as the


data validation is applied to different cells.

Excel ignores data validation formulas that return errors. If a formula


isn't working, and you can't figure out why, set up dummy formulas to make
sure the formula is performing as you expect. Dummy formulas are simply
data validation formulas entered directly on the worksheet so that you can see
what they return easily. The screen below shows an example:

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

The possibilities for data validation custom formulas are virtually


unlimited. Here are a few examples to give you some inspiration:

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))

To allow only unique values:

=COUNTIF(range,A1)<2

To allow only an email address:

=ISUMBER(FIND("@",A1)

Data Validation to Circle Invalid Entries


Once data validation is applied, you can ask Excel to circle previously entered
invalid values. On the Data tab of the ribbon, click Data Validation and select
"Circle Invalid Data":

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":

Copy data validation from one cell to another


To copy validation
from one cell to other cells.
Copy the cell(s) normally that
contain the data validation
you want, then use Paste
Special + Validation. Once
the dialog appears, type "n"
to select validation, or click
validation with the mouse.

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:

To clear all data validation from a worksheet, select the entire


worksheet, then, follow the same steps above.

You might also like