You are on page 1of 4

Business Computing

Session 6

 Outline

› Creating formulas that look up values

› Array formulas

 Creating Formulas That Look Up Values

 A lookup formula returns a value from a table by looking up another related value. A common
telephone directory provides a good analogy.

 Excel provides three basic lookup functions:

› HLOOKUP, VLOOKUP, and LOOKUP.

› In addition, the MATCH and INDEX functions are often used together to return a cell
or relative cell reference for a lookup value.

 The VLOOKUP function

 VLOOKUP(lookup value,table range,column index,[range lookup])

 Lookup value is the value you want to look up in the first column of the table range.

 Table range is the range that contains the entire lookup table.

› The table range includes the first column, in which you try to match the lookup value,
and any other columns in which you want to look up formula results.

 Column index is the column number in the table range from which the value of the lookup
function is obtained.

 Range lookup is an optional argument.

› Optional. If TRUE or omitted, an approximate match is returned. (If an exact match is


not found, the next largest value that is less than lookup_value is returned.) If FALSE,
VLOOKUP will search for an exact match. If VLOOKUP can’t find an exact match, the
function returns #N/A.

 If the range_lookup argument is TRUE or omitted, the first column of the lookup table must
be in ascending order

 If lookup_value is smaller than the smallest value in the first column of table_array, VLOOKUP
returns #N/A

 If the range_lookup argument is FALSE, the first column of the lookup table need not be in
ascending order If an exact match is not found, the function returns #N/A

 If the lookup_value argument is text and the range_lookup argument is FALSE, the
lookup_value can include wildcard characters * and ?

 To compute tax rates based on income?


 For a product ID, how to look up the product’s price?

 Circlar4 Sheet6.xlsx

 Lookup Function

 LOOKUP(lookup value,lookup_vector,result_vector)

› lookup_value: The value to be looked up in the lookup_vector

› lookup_vector: A single column or single row range that contains the values to be
lookup (values must be in ascending order).

› result_vector: The single column or single row range that contains the values to be
returned (same size as the lookup vector).

 HLOOKUP function

 The HLOOKUP function works just like the VLOOKUP function except that the lookup table is
arranged horizontally instead of vertically. The HLOOKUP function looks up the value in the
first row of the lookup table and returns the corresponding value in a specified table row.

 HLOOKUP(lookup_value,table_range,row_index_num,range_lookup)

 The HLOOKUP function’s arguments are as follows

› lookup_value: The value to be looked up in the first row of the lookup table.

› table_range: The range that contains the lookup table.

› row_index_num: The row number within the table from which the matching value is
returned.

› range_lookup: Optional. If TRUE or omitted, an approximate match is returned. (If an


exact match is not found, the next largest value less than lookup_value is returned.)
If FALSE, HLOOKUP will search for an exact match. If HLOOKUP can’t find an exact
match, the function returns #N/A.

 Suppose that a product’s price changes over time. Find the price on a given date.

 Sheet7.xlsx

 INDEX function

 INDEX(Array,Row Number,Column Number)

› INDEX(A1:D12,2,3) returns the entry in the second row and third column of the
A1:D12 array. This entry is the one in cell C2.

› If array contains only one row or column, the corresponding row_num or


column_num argument is optional

 Sheet8.xlsx

 MATCH function

 Enables you to find the first occurrence of a match to a given text string or number within a
given array.
 You should use the MATCH function instead of a lookup function when you want the position
of a number in a range rather than the value in a particular cell.

 MATCH(lookup_value,lookup_range,match_type)

› lookup_value: The value you want to match in lookup_array. If match_type is 0 and


the lookup_value is text, this argument can include wildcard characters * and ?.

› lookup_range: The range being searched.

› match_type: An integer (-1, 0, or 1) that specifies how the match is determined.

› If match_type is 1, MATCH finds the largest value less than or equal to lookup_value.
(lookup_array must be in ascending order.)

› If match_type is 0, MATCH finds the first value exactly equal to lookup_value.

› If match_type is -1, MATCH finds the smallest value greater than or equal to
lookup_value. (lookup_array must be in descending order.) If you omit the
match_type argument, this argument is assumed to be 1.

 MATCH(“Boston”,B4:B11,0) returns 1 if the first row in the B4:B11 range contains the value
Boston Circular4 Sheet9.xlsx

 Lookup1.xlsx

 The OFFSET function

 Use the OFFSET function to create a reference to a range that is a specified number of rows
and columns away from a cell or range of cells.

 OFFSET(reference,rows_moved,columns_moved,height,width).

 =OFFSET(C7,–1,1,1,1). This formula begins in cell C7. It moves one row up and one column to
the right, which takes you to cell D6. The formula now selects a range consisting of one row
and one column, which yields range D6.

 Circluar4 Sheet10.xlsx

 Array Formulas

 In Excel, an array can be one dimensional or two dimensional. Excel doesn’t support three-
dimensional arrays (but its VBA programming language does).

 Excel supports two types of array formulas:

› Single-cell array formulas

› Multicell array formulas

 You enter a normal formula into a cell by pressing Enter. You enter an array formula into one
or more cells by pressing Ctrl+Shift+Enter. Don’t enter the curly brackets when you create an
array formula; Excel inserts them for you.

 {=SUM(B2:B7*C2:C7)}

› Returns a value (single cell array formula)


 {=B2:B7*C2:C7}

› performs its calculations and returns a six-item array (multicell array formula).

 =COUNTIF(Month,“January”)+COUNTIF(Month,“February”)

› counts the number of January or February in the range month.

 {=SUM(COUNTIF(Month,{“January”,”February”}))}

› also gives the same.

 {=SUM(IF(ISERROR(data),1))}

› returns the total number of error values in a range named Data

 {=SUM(LARGE(Data,{1,2,3,4,5,6,7,8,9,10}))} sums the ten largest values in a range named Data

 {=SUM(SMALL(Data,{1,2,3,4,5,6,7,8,9,10}))} sums the ten smallest values.

 the INDIRECT function

 =INDIRECT(A4) returns the value 6 because the reference to A4 is immediately replaced by


the text string “B4”, and the formula is evaluated as =B4, which yields the value 6.

 Summing the n largest values in a range

 {=sum(large(data,row(indirect(“1:10”))))}

 The large function is evaluated 10 times (with 2nd argument from 1 to 10).

 Large returns the kth largest value in the data range

 Row returns the row number

 Circular4 Sheet10.xslsx

 makeuparray.xlsx

 How many units of makeup did Jen sell ?

 {=SUM(IF(F4:F1894="Jen",I4:I1894,0))}

 9537

 Summarize the number of units of each product sold by each salesperson

 {=SUM(($F$4:$F$1894=$B5)*($H$4:$H$1894=$C5)*$I$4:$I$1894)}

 1920 for Ashley (for eye liner)

 Specialized_lookup5.xlsx

You might also like