Академический Документы
Профессиональный Документы
Культура Документы
Example #2
You can also use the IFERROR function to catch the #N/A error thrown
by VLOOKUP when a lookup value isn't found. The syntax looks like
this:
Summary
=IFERROR(VLOOKUP(value,data,column,0),"Not found")
The Excel IFERROR function returns a custom result when a formula
generates an error, and a standard result when no error is detected. In this example, when VLOOKUP returns a result, IFERROR
IFERROR is an elegant way to trap and manage errors without using
functions that result. If VLOOKUP returns #N/A error because a lookup
more complicated nested IF statements. value isn't found, IFERROR returns "Not Found".
Purpose
Trap and handle errors
Notes
Return value
The value you specify for error conditions.
Syntax If value is empty, it is evaluated as an empty string ("") and not
=IFERROR (value, value_if_error) an error.
Arguments If value_if_error is supplied as an empty string (""), no message
value - The value, reference, or formula to check for an error. is displayed when an error is detected.
value_if_error - The value to return if an error is found. If IFERROR is entered as an array formula, it returns an array of
Usage notes results with one item for each cell in value.
The IFERROR function "catches" errors in a formula and returns an In Excel 2013+, you can use the IFNA function to trap and handle
alternative result or formula when an error is detected. #N/A errors specifically.
Use the IFERROR function to trap and handle errors produced by other
formulas or functions. IFERROR checks for the following errors: #N/A,
#VALUE!, #REF!, #DIV/0!, #NUM!, #NAME?, or #NULL!.
The IFERROR function takes two arguments: a value (usually entered as
a formula), and a result to display if the formula returns an error. The
Basic error trapping example second argument is only used if the first argument throws an error.
In this case, the first argument is the simple formula for calculating the
average order size, which divides total sales by the order count:
=C5/D5
Generic formula
=IFERROR(formula,value_if_error)
Explanation
To catch errors that a formula might trigger in a worksheet, you can use
the IFERROR function to display a custom message, or nothing at all.
=IFERROR(C5/D5,"")
In this example, the IFERROR function is used to trap and suppress the
#DIV/0! error that occurs when there is no value for Orders (column D).
Without IFERROR, the formula C5/D5 would display a #DIV/0! error in
E6 and E9.
If you have data organized horizontally, use the HLOOKUP function.
Summary VLOOKUP only looks right
VLOOKUP is an Excel function to lookup and retrieve data from a
specific column in table. VLOOKUP supports approximate and exact
matching, and wildcards (* ?) for partial matches. The "V" stands for VLOOKUP requires a lookup table with lookup values in the left-most
"vertical". Lookup values must appear in the first column of the table, column. The data you want to retrieve (result values) can appear in any
with lookup columns to the right. column to the right:
Purpose
Lookup a value in a table by matching on the first column
Return value
The matched value from a table.
Syntax
=VLOOKUP (value, table, col_index, [range_lookup])
Arguments
value - The value to look for in the first column of a table.
table - The table from which to retrieve a value.
col_index - The column in the table from which to retrieve a
value.
range_lookup - [optional] TRUE = approximate match (default).
FALSE = exact match. VLOOKUP retrieves data based on column number
When you use VLOOKUP, imagine that every column in the table is
Usage notes numbered, starting from the left. To get a value from a particular column,
provide the appropriate number as the "column index". For example, the
VLOOKUP is designed to retrieve data in a table organized into vertical column index to retrieve first name below is 2:
rows, where each row represents a new record. The "V" in VLOOKUP
stands for vertical:
VLOOKUP has two matching modes, exact and approximate Example 2: Approximate match
VLOOKUP has two modes of matching: exact and approximate, which In cases when you want the best match, not necessarily an exact match,
are controlled by the 4th argument, called "range_lookup". Set you'll want to use approximate mode. For example, below we want to
range_lookup to FALSE to force exact matching, and TRUE for look up a commission rate in the table G5:H10. The lookup values come
approximate matching. from column C. In this example, we need to use VLOOKUP in
approximate match mode, because in most cases an exact match will
Important: range_lookup defaults to TRUE, so VLOOKUP will use never be found. The VLOOKUP formula in D5 is configured to
approximate matching by default: perform an approximate match by setting the last argument to TRUE:
=VLOOKUP(value, table, column) // default, approximate
match
=VLOOKUP(value, table, column, TRUE) // approximate
match
=VLOOKUP(value, table, column, FALSE) // exact match
VLOOKUP will scan values in column G for the lookup value. If an exact match
is found, VLOOKUP will use it. If not, VLOOKUP will "step back" and match
the previous row.
Note: data must be sorted in ascending order by lookup value when you use
approximate match mode with VLOOKUP.
VLOOKUP and #N/A errors
The formula in H6 to find Year based on an exact match of movie title is:
=VLOOKUP(H4,B5:E9,2,FALSE) // FALSE = exact match If you use VLOOKUP you will inevitably run into the #N/A error. The #N/A
error just means "not found". In practice, there are many reasons why you might
see this error. Among the most common:
=IFNA(VLOOKUP(H4,B5:E9,2,FALSE),"Not found")