excel-lecture
excel-lecture
ERROR VALUE
A type of data that Excel displays if Excel cannot properly evaluate a formula in a cell.
#NULL The formula specifies the two areas that do not intersect
#VALUE The value is not the type expected by the argument or the
range being evaluated does not intersect.
Formulas in Excel always begin with an equal (=) sign and can include number and
text values (constant), arithmetic operators, comparison operators, text operators, functions,
parentheses, cell reference and names. By combining these components, you can calculate
the result you want by using the information in a worksheet.
Excel follows consistent rules when applying operators in formula. The table evaluates
operation in order.
Operator Definitions
: Range
Space Intersect
, Union
- Negation
% Percentage
^ Exponentiation
*and/ Multiplication and Division
+ and - Addition and Subtraction
& Text joining
=, <, and <= Comparisons
>, >=, and <>
The following are the most commonly used keys in moving around a worksheet.
Key Movement
Any arrow key One cell in the direction of the arrow
Home To column A
Alt + PgUp Left one sheet screen
Alt + PgDn Right one sheet screen
Ctrl + PgDn To the next sheet in the workbook
Ctrl + PgUp To the previous sheet in the workbook
Ctrl + Home To the start of the row containing the active cell
Ctrl + End Along the current row to the right most column in the
sheet that contains data.
Tab Enters data and moves the active cell right
Shift + Tab Enters data and moves the active cell left
Enter Enters data and moves the active cell down
Shift + Enter Enters data and moves the active cell up in the selected
range
Ctrl + arrow Moves the active cell in the direction arrow end + arrow
indicated until the edge of a block of data is reached
It is important that you understand the following rules when using the Vlookup function in Excel:
• The Vlookup function does not recognise numbers and text representations of numbers as being equal.
Therefore, if your lookup_value is equal to the text string "10", but the values in thetable_array are numeric,
the function will fail to find a match.
• The Vlookup function considers all characters (including spaces) when searching for a match. Therefore, the
two text strings, "text" (no spaces) and "text " (with trailing spaces) are not an exact match.
Rules for the Vlookup Using an Exact Rules for the Vlookup Using the Closest
Match Match
If the [range_lookup] argument is set to If the [range_lookup] argument is set to TRUE
FALSE, the Vlookup searches for an (or omitted), the lookup_value is matched to
exact match to the lookup_value. If an the closest value below or equal to this value.
exact match is not found, the function Therefore, if the [range_lookup] argument is
returns the #N/A error. TRUE, the following rules apply:
In this case, the following rules apply: • The left hand column of the
suppliedtable_array must be in ascending order. If
• If the lookup_value is duplicated in the
it isn't, the function may return unpredictable
left-hand column of the table_array, the
results.
function uses the first match that it
• If the lookup_value is smaller than all of the values
encounters.
in the left-hand column of the table_array, the
• If the lookup_value is a text string, you can
Vlookup function returns the #N/A error
use wildcard characters, where the
character ? matches any single character
and the asterix, * matches any set of
characters. For example,
a lookup_value"t*" would match any text
string beginning with the character "t".
Common Vlookup Errors
#N/A - Occurs if the Vlookup function fails to find a match to the supplied lookup_value.
The cause of this will generally depend on the supplied [range_lookup] argument:
if [range_lookup] = TRUE - the #N/A error is likely to be because the smallest value in the left-hand
(or is omitted) column of the table_array is greater than the supplied lookup_value.
If you still can't understand why you are getting this Vlookup error, check out the Vlookup #N/A Error
page.
• The supplied col_index_num argument is greater than the number of columns in the
supplied table_array.
or
• The formula has attempted to reference cells that do not exist.
This can be caused by relative referencing errors when the Vlookup is copied to
other cells.
If you need further help with this Vlookup error, check out the Vlookup #REF! Error page.
Incorrect - If your Vlookup function is simply returning the wrong value, check the following:
Value
Returned 1. Are the values you are searching in the left column of the table_array?
For the Vlookup function to work, the values that you are searching must be in the
left column of the table_array.
2. If the [range_lookup] argument is set to TRUE (or omitted), the function will return
the closest match below the lookup_value. For this to work correctly, the left column
of the table_array must be in ascending order.
Vlookup Syntax
table_array - The array of data that is to be searched for the lookup_value. The Vlookup
function searches in the left-most column of the table_array.
col_index_num - The column number of the supplied table_array, that you want to return a
value from.
[range_lookup] - An optional logical argument, which describes what the function should
return in the event that it does not find an exact match to
thelookup_value.
The [range_lookup] can be set to TRUE or FALSE, meaning:
Note: when we drag the VLOOKUP function down, the absolute reference ($E$4:$G$7) stays the same, while the relative
reference (A2) changes to A3, A4, A5, etc.
In some situations, an approximate match is preferred, so several values will return the same
result. For example, when grading student papers, all papers with a grade of 85 or over
should receive an A grade.
the lookup table is created on a sheet named Grades. To create the lookup table, enter the
minimum score for each grade in column A. Enter the matching Grade in column B. Sort the
Scores in Ascending order.
The scores are entered on a sheet named Report Card, where a VLOOKUP formula
calculates the grade.
1. On the Report Card sheet, in cell B4, enter the score 77.
2. In cell C4, enter the VLOOKUP formula:
=VLOOKUP(B4,GradeList,2,TRUE)
3. Press the Enter key, and the grade for English -- B -- is returned.
In the screen shot below, the formula has been copied down to row 6, and the you can see the
formula in cell C6.
HLookup
In a similar way, you can use the HLOOKUP (Horizontal lookup) function.
Match
The MATCH function returns the position of a value in a given range.
Note: Yellow found at position 3 in the range E4:E7. The third argument is optional. Set this argument to 0 to return the position
of the value that is exactly equal to lookup_value (A2) or a #N/A error if not found.
Index
The INDEX function returns a specific value in a two-dimensional or one-dimensional range.
Note: 92 found at the intersection of row 3 and column 2 in the range E4:F7.
Note: 97 found at position 3 in the range E4:E7.
Choose
The CHOOSE function returns a value from a list of values, based on a position number.
Two-way Lookup
This example teaches you how to lookup a value in a two-dimensional range. We use the MATCH and INDEX function.
Below you can find the sales of different ice cream flavors in each month.
To see the steps for setting up the IF and VLOOKUP formula, you can watch this short video.
The written instructions are below the video.
1. On the Invoice sheet, in cell A8, enter the product code A28. If the VLookup formula in cell
B8 has FALSE as the fourth argument, the result is #N/A, because there is no exact match for
the product code in the lookup table.
2. Wrap the VLookup formula with an IF formula (in this example the product list has been
named), using the ISNA function to check for an #N/A error:
=IF(ISNA(VLOOKUP(A8,ProductList,2,FALSE)),"",VLOOKUP(A8,ProductList,2
,FALSE))
3. Press the Enter key, and cell appears blank. Because no exact match was found, the VLookup
formula returned an #N/A, so the ISNA function result is TRUE. The IF formula converted this
to an empty string.
If the lookup table contains any blank cells, a VLOOKUP formula will return a zero, instead of
a blank cell. You can use nested IFs to handle the #N/A results, and the empty cell results.
For example:
=IF(ISNA(VLOOKUP(A8,ProductList,2,FALSE)),"",
IF(VLOOKUP(A8,ProductList,2,FALSE)="","",
VLOOKUP(A8,ProductList,2,FALSE)))
Combine IFERROR and VLOOKUP
Thanks to Chip Pearson for suggesting this formula.
In Excel 2007, a new function, IFERROR, was introduced. You could use an IFERROR
formula with VLookup to check several tables for a value, and return the related information
when found. In this example, three regions, West, East and Central, have order sheets. On
each sheet is a named range -- OrdersW, OrdersE and OrdersC.
On a sheet named Orders, you can enter an Order ID, then use a VLOOKUP with IFERROR to
check each named range, and view the information about the selected order.
1. On the Order sheet, in cell B6, enter a 4 as the OrderID. That order was placed in the Central
region.
2. To simply check the East region's table, the VLOOKUP formula in cell C6 would be:
=VLOOKUP(B6,OrdersE,2,FALSE)
3. Press the Enter key, and the VLOOKUP formula returns an #N/A, because Order ID 4 is not in
the East regions order table.
4. Because an order could have been placed in any of the three regions, you need a formula that
will check each table.
If the order ID is not found in the first table, the formula should check second table. If the
order ID is not in the second table, it should check the third table. If the order ID isn't in the
third table, then a "Not Found" message should appear in the cell.
5. The IFERROR formula lets you check a value, then specify what to do if an error is found. If
you use IFERROR with the existing formula, you can show "Not Found", instead of the #N/A
error:
=IFERROR(VLOOKUP(B6,OrdersE,2,FALSE),"Not Found")
6. To check all three tables, you can next IFERROR and VLOOKUP formulas:
=IFERROR(VLOOKUP(B6,OrdersE,2,FALSE),
IFERROR(VLOOKUP(B6,OrdersW,2,FALSE), IFERROR(VLOOKU
P(B6,OrdersC,2,FALSE),"Not Found")))
This checks the OrdersE table and if an error is found, checks OrdersW table, then OrdersC. If
the OrderID is not found in any of the three tables, the Not Found message is shown in the
cell.
You can also check multiple tables in older versions of Excel, where IFERROR is not
available, using a longer formula:
=IF(NOT(ISERROR(VLOOKUP(B8,OrdersE,2,FALSE))),
VLOOKUP(B8,OrdersE,2,FALSE),
IF(NOT(ISERROR(VLOOKUP(B8,OrdersW,2,FALSE))),
VLOOKUP(B8,OrdersW,2,FALSE),
IF(NOT(ISERROR(VLOOKUP(B8,OrdersC,2,FALSE))),
VLOOKUP(B8,OrdersC,2,FALSE),"Not Found"))))
If you need to find the price for a large jacket, a VLOOKUP based only on column A would
return the price for the first jacket listed (Medium). You would be underpricing the jacket --
selling it for 60.00, instead of 65.00.
To create unique lookup values, you can insert a new column at the left side of the table, and
use a formula to combine the product and size. In cell A2, the formula combines the value in
B2 and the pipe character and the value in C2.
Note: Instead of the pipe character, you could use another character that isn't included in
your data.
Then, in a VLOOKUP formula, combine the product and size as the Lookup_value. In cell H1,
the formula combines the value in F1 and the pipe character and the value in G1.
If possible, convert the text to numbers, using one of the methods shown here: Convert Text
to Numbers
If you can't convert the data, you can convert the lookup value within the VLOOKUP formula:
=VLOOKUP(--A7,Products!$A$2:$C$5,3,FALSE)
The double unary (--) converts text to a number, and will work correctly even if the lookup
values are numbers.
Lookup values are Numbers, and the table contains Text
If the lookup table contains text, and the value to look up is numeric, use a formula similar to
the following:
To see the steps for fixing the VLOOKUP problem when the lookup table has text values,
watch this short video tutorial.
If possible, remove the unnecessary spaces, and the VLOOKUP formula should work
correctly. If you can't remove the spaces, use the TRIM function in the VLOOKUP, to remove
leading, trailing or duplicate spaces. For example:
=VLOOKUP(TRIM(A7),ProductList,2,FALSE)
http://www.contextures.com/xlFunctions02.html