Error Values and the IFERROR Function

advertisement
Computer Data Analysis
CGS 2518
Instructor: Greg Shaw
Error Values and the IFERROR Function
 Error Values

If Excel cannot properly evaluate a formula or function, an error
value (e.g., #REF!) will be displayed in the cell and a green
triangle will appear in the upper-left-hand corner

As shown in the following table, error values consist of the
pound sign (#) followed by the error name
Error
Value

Description
Common Cause
#DIV/0!
Division by zero
A formula or function contains a
number divided by zero
#NAME?
Excel doesn’t
recognize a name
used in a formula
Misspelled function name, cell or
range name, or forgetting to
enclose text values in a function
in quotes
#N/A!
A value is not
available to a
formula or function
A value specified in VLOOKUP is
not found in the table
#NUM!
Invalid numbers
used
Text is entered into a function
where a number is required
#REF!
Invalid cell
reference in a
formula or function
One or more cells referenced by
the formula/function have been
deleted from the sheet
#VALUE!
Wrong type of
argument used in a
formula/function
A cell range is entered into a
function where a single cell
reference is required
When you select a cell containing
indicator icon appears to its left
an
error
value,
an
error
o
Point to the icon and a Screen Tip explaining the error will
appear
o
Click the error indicator button for
including detailed Help on the error
a
list
of
options,
 Using the IFERROR Function

The IFERROR function is used to display a more descriptive
message when an Error Value would otherwise be displayed in a
cell

Syntax:
o
expression is the function whose result will display in the
cell if no error occurs
valueIfError is the message that will be displayed instead if
an error occurs
o

=IFERROR(expression, valueIfError)
E.g., XYZ has decided to assign a job classification code based
on store location, as shown in this table, which is in the range
F15:G18
Store Location
Code
Greensburg
1
Cranberry
2
South Hills
3
Monroeville
4
To determine whether an invalid store location has been entered
in the Store column (column B) of the XYZ Security Systems table,
we would enter this function in cell I5 (the Job Classification
column):
=IFERROR(VLOOKUP(B5,$F$15:$G$18,2,FALSE),"Invalid Location!")
Now, if B5 contains a valid location - Greensburg, Cranberry,
South Hills, or Monroeville - the corresponding job code will be
returned and stored in I5.
Otherwise, “Invalid Location!” will
display in I5

Note that the optional 4th argument to VLOOKUP must be used
and set to FALSE since we are doing an “exact match” lookup
(as opposed to a “range” lookup)
Download