Anda di halaman 1dari 18

# BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 1 of 13

MS EXCEL 2003

VLOOKUP

## THE VLOOKUP FUNCTION

Notes:
The VLOOKUP function allows you to search for a value in one table and return
a value or label from the table to a cell in the spreadsheet. The VLOOKUP
function could be used to:
• Price items based upon quantity sold
• Convert a student’s percent to a letter grade
• Assign commission rates based upon products sold
• Assign an income tax rate based upon level of income

## = VLOOKUP(VALUE, TABLE LOCATION, COLUMN)

The value you want to The location of the The number of the
find a match for in the VLOOKUP table you column containing
VLOOKUP table created. Use an absolute the matching value
cell reference for this that you want
location in the function. returned. Usually
this is 2

## The way VLOOKUP works is as follows:

• It takes the lookup value and compares it to each number in the first
column of the lookup table, beginning at the top of the column
• If it finds an exact match, it moves to the second column and returns
that value to the cell
• If there is no exact match, it goes down the first column of the lookup
table until it finds the first number larger than the lookup value
• It then moves up one row, moves to the column to the right and returns
the value

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 1 of 13
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 2 of 13

MS EXCEL 2003

VLOOKUP

## Background Reading: Converting Student Percentages to Letter

The illustration below shows a VLOOKUP table for converting
student marks from percentages to letter grades according to reading only. There is no
a possible system of equivalences (used in some U.S. hands-on exercise for you
schools). to do.

## The VLOOKUP function showing in the formula bar works

as follows:
• B2 tells the function to compare cell B2 to the first
column of the lookup table
• \$D\$2:\$E\$14 tells the function where the lookup table is
located (notice that it does not
include the titles).
• The function takes the
value 98, compares it to the first
cell in the first column of lookup
table, detects that 98 is larger
than 0, so advances down to the
next cell of the table. Again it
detects that 98 is larger than 60,
so it advances downward again. It
repeats this process until it
finds a value in the table that is
equal to 98. In our example, it
finds that cell D14 in the table
is equal to 98. The function then
looks at its third parameter.
• 2 tells the function to return whatever is in the second
column of the lookup table. In our example, the cell in question,
E14, contains A+, so the function enters A+ in its target cell C2.
• In our example, the function found an exact match between
the first parameter, B2, and a cell in the lookup table, D14. But
what happens when the function doesn’t find an exact match? It
continues down the leftmost column of the table until it detects a
value greater than B2. Then it moves back up to the previous cell in
the table.

## This lookup table shows values for the

temperature and viscosity of air at 1 atm air
pressure.
• the function =VLOOKUP(1,A2:C10,2) looks up
1 in column A, and returns the value from
column B in the same row (2.17)

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 2 of 13
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 3 of 13

MS EXCEL 2003

VLOOKUP

## Study this worksheet. Can you

explain the results in B8 and B9?

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 3 of 13
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 4 of 13

MS EXCEL 2003

VLOOKUP

Exercises —
Ex. 1 A walk-through example
1. Open a new workbook named Excel_vlookup_ex5a.xls with 2 worksheets.
Right-click on the worksheet tabs at the bottom of the Excel screen to
rename Sheet 1 as Data and Sheet 2 as Suppliers.

## One useful feature of VLOOKUP is that it allows you to point multiple

worksheets and cells to one lookup list.
2. Create the lookup list in the Suppliers worksheet as below.

## 3. Next set up the Data worksheet.

4. Note that the Supplier ID and Supplier Name fields are repeated in this
sheet. We will enter the Supplier ID only; VLOOKUP will automatically
enter the Supplier Name.

## 6. Enter 103 into E2.

7. Click in F2. We’ll use VLOOKUP to get the Supplier Name.

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 4 of 13
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 5 of 13

MS EXCEL 2003

VLOOKUP

8. Enter the VLOOKUP function by clicking on the down arrow next to the
AutoSum button ∑ on the Standard toolbar. Select More Functions. The
Insert Function dialog box opens.

## 9. Type vlookup into the box labeled Search for a function.

10. Click on Go.
11. Select VLOOKUP.
12. Click OK. The Function Arguments dialog box opens.
Pause to read the description of how the VLOOKUP function works near
the bottom of the dialogue box.

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 5 of 13
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 6 of 13

MS EXCEL 2003

VLOOKUP

13. In the dialogue box labeled Lookup_value enter E2 (that is, the
cell holding the Supplier ID).
Or you can click on the small red arrow, select E2, then press Enter.
Here’s how VLOOKUP will work. It will
i. compare the contents of E2 . . .
ii. with the first column (Supplier ID) of the lookup
table, then . . .
iii. input the Supplier Name that’s paired with the ID
into the current cell (that is, the cell where you’re
putting the function) or F2.
14. Table_array is the lookup table.
i. Click on the red arrow in the bottom corner of the
table_array box
ii. Click on the Suppliers sheet.
iii. Select A2:B7.

## 15. Col_index_number indicates the column of your lookup table that

you want entered into the current cell. In this case it is the Supplier
Name data which is the second column of the lookup table. (Note:
Usually we use 2 for column index number. Later you will learn about
when to use other column numbers.)
i. Type 2 in the box.
16. In the Range_lookup box
i. Type the word false.
The purpose of false is made clearer in the Enrichment section
below. However, to explain briefly, this ensures that VLOOKUP
searches for an exact match, not merely a close match.
17. Click on OK.
The formula bar for cell F2 shows the following:
=VLOOKUP(E2,Suppliers!A2:B7,2,FALSE)
Notice the exclamation mark after Suppliers, indicating the name
of the second worksheet.
18. Press F4 to make the lookup table references absolute.
Important: If you are going to copy a VLOOKUP function to other cells,
be careful to make the cell references for the lookup table absolute.
The location of the lookup table does not change.
19. Copy the VLOOKUP function from F2 to F3:F7.

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 6 of 13
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 7 of 13

MS EXCEL 2003

VLOOKUP

## 20. Test it by entering in E3:E8 the following SupplierID numbers:

i. 103, 105, 101, 104, 102, 106.
Look at the Suppliers sheet. See whether the correct supplier names
have been input into F3:F7.

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 7 of 13
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 8 of 13

MS EXCEL 2003

VLOOKUP

## Ex. 2 Using VLOOKUP to convert a student’s mark to a letter

A school might assign criteria for letter grades as follows:
A mark of less than 50 receives a letter grade of F, 50 or more but
less than 60 receives a D, 60 or more but less than 70 receives a C, 70
or more but less than 80 receives a B, 80 or more but less than 90
We might express that as follows:
Note:
50>mark F It is usually your job to
60>mark>=50 D figure out how to set up
Our job is to turn your lookup table. The
70>mark>=60 C information given to us information you will be
given is normally in
80>mark>=70 B in this form into a
English or in
VLOOKUP table. mathematical form as in
90>mark>=80 A
this example.
A+ mark>90 A+

First a VLOOKUP table is created using given criteria (see below, A2:B7)
Then the VLOOKUP function is added to the spreadsheet to create the
conversion

A B C D E F
1 VLOOKUP function syntax
VLOOKUP Jane’s created in cells E3:E5
TABLE Marks
2 0 F Percent Letter

3 50 D 78 B =VLOOKUP(D3, \$A\$2:\$B\$7,2)
4 60 C 65 C =VLOOKUP(D4, \$A\$2:\$B\$7,2)
5 70 B 92 A+ =VLOOKUP(D5, \$A\$2:\$B\$7,2)
6 80 A
7 90 A+
1. Read and review the VLOOKUP function theory on the first page.
2. Open a new worksheet named Excel_vlookup_ex2.xls.
3. Duplicate the spreadsheet cells of A1:D7 as illustrated. Do NOT copy
4. In cell E3, add the VLOOKUP function shown in F3. (You may use the
Paste Function button, or select Insert / Function, or type into the cell,
or type into the formula bar.)

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 8 of 13
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 9 of 13

MS EXCEL 2003

VLOOKUP

5. Copy the function down to cells E4:E5. Your Column E should look like
the illustration.
6. Save the file.
Ex. 3 Using VLOOKUP to assign a discount for quantity
purchases
For a series of purchases by customers, we want to
enter the number of units sold, and have Excel Requirements for this type of
automatically give us a price per unit. The price Vlookup Table:
will vary according to how many units are sold. • Numbers in first column
We’ll use a quantity discount table and the must be in ascending order
VLOOKUP function. • no duplications.

1. Create the Discount Price Table to be used in the VLOOKUP function (see
illustration).
i. Purchases of 1-49 units have a per unit price of \$10.00
ii. At 50-99 units, the price drops to
\$9.50.
iii. At 100-199 units the price is
\$9.00
iv. Over 200 units the price is \$8.50.
2. Save as Excel_vlookup_ex3.xls
3. Create the Sales Summary section below the
Discount Price Table as illustrated.
4. In B9 enter a VLOOKUP function to return the
price to the spreadsheet as follows:
The function will look up the value of 50 from cell A9 in the Discount
Price Table \$A\$2:\$B\$5 and return the price of \$9.50 from the second
column of the VLOOKUP table to cell B9.
5. Copy the VLOOKUP function from B9 to B10:B18. Since the table reference
in our function is absolute (\$A\$2:\$B\$5 ) we can copy the function down
the column.
6. Format the column to show currency and 2 decimals.
7. Enter a formula to calculate Total Sales which is simply Units Sold
times Price.
8. Format the column to show currency and 2 decimals.
9. Print two copies (these two printouts will be useful for study and
review purposes):
i. the selection range of A7:C18 (excluding the VLOOKUP table)
showing values and formatting, centered vertically and horizontally
on the page.
ii. the entire spreadsheet showing formulas, on a single page,
showing gridlines and row & column headings

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 9 of 13
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 10 of 13

MS EXCEL 2003

VLOOKUP

## Be careful to understand the difference between -

discount a percentage such as 15%
rate Example: =VLOOKUP(1,A2:C10,2)
Our exercises have used VLOOKUP to find a discount rate.
discount a dollar figure such as \$48.35, resulting from a
amount calculation using the discount rate
In a single formula we can calculate the discount
amount. We can use VLOOKUP to find a rate, then multiply
the result by a cell holding the sales amount.
Example: =VLOOKUP(1,A2:C10,2) * D2

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 10 of 13
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 11 of 13

MS EXCEL 2003

VLOOKUP

Ex. 4 Practice
Overview: You have recently been hired by Fast Air Service as Area Sales
Manager for the Southern Ontario region. At the end of the month one of your
jobs is to calculate the salary of your salespeople. Your boss wants you to
do it by creating an Excel template, using the VLOOKUP function, so that you
can quickly calculate your department’s monthly salary at the end of every
month.
• The monthly salary for each salesperson includes a base salary of
\$2,000 plus a commission amount based upon their monthly sales figure.
• Commission rate scale:
Monthly Sales Commission Rate
Less than \$5000 0%
\$5000 to \$7499.99 5%
\$7500 to \$9999.99 7.5%
\$10000 to \$14999.99 10%
Greater than \$15000 15%
• Sales personnel by area
Sales Representative Area Office
Jonathan Small Mississauga
Ida Fung East York
Yves St. James Toronto
Parminder Singh Scarborough
Donna Cooke Hamilton
Glenn Bracey London

1. Create an Excel template to calculate the monthly salary amounts for each
• Main title (e.g. Fast Air Service, Southern Ontario)
• Sub title (Sales Department Monthly Report)
• Column headings of “Sales Representative”, “Area Office”, “Monthly
Sales Amount”, “Base Salary”, “Commission Rate”, “Commission Amount”
and “Total Monthly Salary”
• Use the VLOOKUP function to return the Commission Rate to the
spreadsheet. Create the VLOOKUP table using the Commission rate

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 11 of 13
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 12 of 13

MS EXCEL 2003

VLOOKUP

## descriptions in the table above and use them to create a lookup

table.)
• Create formulae to calculate the Commission Amount and Total Monthly
Salary
2. Save the file as a template named Excel_vlookup_template_ex4.xlt
3. Use the template file three times to create a workbook name
Excel_vlookup_April.xls to calculate the Monthly Salary for all six
salespeople for April, another workbook named Excel_vlookup_May.xls for
May and a third workbook named Excel_vlookup_June.xls for June. Use the
data below.

## Monthly Sales Amount by Sales

Representative
Sales Representative April May June
Jonathan Small \$6190.00 \$8400.00 \$7500.00

## Ida Fung \$7820.00 \$4600.00 \$10500.00

Yves St. James \$5000.00 \$8800.00 \$7500.00
Parminder Singh \$9150.00 \$6500.00 \$17500.00
Donna Cooke \$10200.00 \$6600.00 \$2500.00
Glenn Bracey \$4500.00 \$16000.00 \$9500.00

4. Create a Quarterly Salary Summary for the months of April, May and June.
• Main title
• Sub title
• Sales Representative
• Area Office
• Total Monthly Salary - April
• Total Monthly Salary - May
• Total Monthly Salary - June
5. Save the linked file as Excel5_vlookup_salessummary.xls

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 12 of 13
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 13 of 13

MS EXCEL 2003

VLOOKUP

Enrichment
The section below is for students who have finished their work before the
rest of the class. It will give you a higher level of expertise with
Microsoft Word 2003.
This material will not appear on tests.

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 13 of 13
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 14 of 13

MS EXCEL 2003

VLOOKUP

## Using the “false” parameter

In the last few exercises we focused on VLOOKUP when
• the lookup table is arranged in sequence from lowest to highest, and
• the value you give to the function may not exactly match a number in
the table—for
example when a student's mark is 76 and your table shows 60, 70, 80,
etc. but not
76.
But what happens when data in the table is not arranged in sequence, or when
you want the function to give a result only for an exact match? The VLOOKUP
function offers an additional parameter, FALSE, to deal with these cases.

## Ex. 5 Returning only exact matches with VLookup

Consider a table with the data in numerical sequence but where you want
returns for only exact matches. A good example would be a table of data on
students, with the first column holding student numbers, the next column
holding telephone numbers, and further data in additional columns. See
illustration.
You want to match the student number to
other information. However, you certainly do
not want "approximate" results, that is, the
lookup function returning results for a
student whose student number is less than
the number you are trying to match. You want
only exact matches.
1. Create an Excel worksheet named
Excel_vlookup_5.xls as illustrated.
2. In B11 enter a VLOOKUP function.
i. the lookup value is A11
ii. the Table Array is
\$A\$2:\$C\$5 (remember with VLOOKUP to
use absolute cell addresses for the location of the table)
iii. the Column Index Number is 2
iv. Click on OK. The student name Yukio Tojo will appear in
B11.
3. Copy down the function to B12 and B13.
4. In A14 enter the following number, which does not represent a real
student in the table:
309799001.

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 14 of 13
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 15 of 13

MS EXCEL 2003

VLOOKUP

5. Copy down the function in B13 to B14. Do you understand why B14 shows the
name Yukio
Tojo even though 309799001 is not her student number?
(Answer: VLOOKUP worked by looking down column A of the lookup table
until it found a number larger than the given number, 309799001. It
stopped at that position, A5, then moved back up one position to A4 and
returned data from the second column, which you specified in the
function.)
6. Now copy down the function in C13 to C14. Notice whose telephone number
appears in C14.
Can you explain why VLOOKUP returned that telephone number?
The FALSE Parameter — By adding a fourth "parameter" to the VLOOKUP function,
we can avoid the problem of an inaccurate results. The parameter FALSE forces
VLOOKUP to return only exact matches, giving an error message when no exact
match can be found.
7. Click in cell B11.
8. In the formula bar add FALSE to the function as follows:
=VLOOKUP(A11,\$A\$2:\$C\$5,2, FALSE) .
9. Press Enter.
10. CopyB11 down to B12:B14.
11. An error message appears in B14. Why is this the result you
want?
12. Click in cell C11.
13. In the formula bar add FALSE to the function as follows:
=VLOOKUP(A11,\$A\$2:\$C\$5,3,FALSE).
14. Press Enter.
15. CopyC11downtoC12:C14.
11. An error message appears in C14. Why is this the result you want?

## Ex. 6 Using VLOOKUP tables that are not in sequential order

Another situation where you want VLOOKUP to find only an exact match is when
the data in the first column is not in ascending (sequential) order. The
example we considered above was a table of student information arranged in
sequence by student number. Let’s see what happens if the data is not in
order by student number.
1. Save a second copy of the worksheet created above as
Excel_vlookup_ex6.xls
2. Delete the VLOOKUP functions in B11:C14.
3. Highlight the lookup table A2:C5.

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 15 of 13
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 16 of 13

MS EXCEL 2003

VLOOKUP

4. Select Data / Sort / Sort by: Name (Col. B) to re-sort the data so that
it is not in order by student number.
5. In B11 enter the VLOOKUP function as earlier, with no FALSE parameter.
6. In C11 enter the VLOOKUP function as earlier, with no FALSE parameter.
7. Copy down B11:C11 to B12:C14.
8. Are the results correct? Can you explain them?
9. In B11 and C11 edit the functions by adding the FALSE parameter.
10. Copy down B11:C11 to B12:C14.
11. Are the results correct now? Can you explain them all, including B14
and C14?

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 16 of 13
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 17 of 13

MS EXCEL 2003

VLOOKUP

BONUS ASSIGNMENT 1

## Create an order form for Toronto Discount Computer Land

You are the manager of a computer warehouse, Toronto Discount Computer
Land, selling hardware to small computer stores. When companies buy in
bulk, they qualify for discounts up to 33%. Because your prices change
regularly, it is important that your 'data table' be updated easily, and
the resulting invoice reflects these changes.
You will design a spreadsheet (see below) that consists of a 'master
lookup table' containing your current price sheet, followed by an actual
Order Form for the client.
N.B. The user will be required to enter only two pieces of information in
the Order Form, namely the Quantity and Item Number. The remainder of the
Order Form will fill in automatically (via your formulas).

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 17 of 13
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 18 of 13

MS EXCEL 2003

VLOOKUP

BONUS ASSIGNMENT 2

## Create a VLOOKUP table with more than 2 columns

Below is an Excel worksheet that helps a shipping clerk decide the best
method of delivering a shipment based on its weight. When the clerk enters
the weight of the shipment in C13 or below, the worksheet automatically
determines the cost of shipping by courier (D13), the lowest shipping cost
(E13), and the best mode based on the shipping cost (F13).

## Follow the example to create a worksheet named Excel5_B2.xls. Add the

required VLOOKUP functions in D13:F15. Note: In this example the third
parameter of the VLOOKUP function will not always be 2.

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit 2: Spreadsheet – Part 5: The VLOOKUP Function – Page 18 of 13