0% found this document useful (0 votes)
20 views17 pages

ExcelMath4 Vlookup

This document provides a comprehensive guide on using the VLOOKUP function in Excel, including its syntax, examples, and common pitfalls. It also covers related functions such as IF, IS, IFNA, and IFERROR, along with practical exercises to reinforce learning. The training is designed for both classroom and Zoom sessions, aimed at enhancing Excel skills for data management.

Uploaded by

alefdougzerihun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views17 pages

ExcelMath4 Vlookup

This document provides a comprehensive guide on using the VLOOKUP function in Excel, including its syntax, examples, and common pitfalls. It also covers related functions such as IF, IS, IFNA, and IFERROR, along with practical exercises to reinforce learning. The training is designed for both classroom and Zoom sessions, aimed at enhancing Excel skills for data management.

Uploaded by

alefdougzerihun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Excel Math: vLookup

[email protected]
Excel Math 4: vLookup Statements
1.5-hour Classroom* / 1.0-hour Zoom Session
* Classroom sessions include time to repeat exercises for practice
VLOOKUP Worksheet Function ....................................................................................................... 3
Description .................................................................................................................................. 3
Remarks....................................................................................................................................... 3
Syntax: VLOOKUP( ) ..................................................................................................................... 3
Data Validation: Insert or delete a drop-down list.......................................................................... 5
IF Worksheet Function .................................................................................................................... 6
Syntax: IF( ) .................................................................................................................................. 6
Remarks....................................................................................................................................... 6
Logic Tree .................................................................................................................................... 6
IS Worksheet Functions ................................................................................................................... 7
Description .................................................................................................................................. 7
Syntax: IS( ) .................................................................................................................................. 7
Remarks....................................................................................................................................... 7
Note from Pandora ..................................................................................................................... 8
IFNA Worksheet Function ............................................................................................................... 8
Description .................................................................................................................................. 8
Syntax IFNA ................................................................................................................................. 8
Remarks....................................................................................................................................... 8
IFERROR Worksheet Function ..................................................................................................... 8
Description .................................................................................................................................. 8
Syntax .......................................................................................................................................... 8
Remarks....................................................................................................................................... 8
Class Exercises ................................................................................................................................. 9
Phone Lookup (vLookup) ............................................................................................................ 9
Title Lookup (vLookup) .............................................................................................................. 10
PayRate (when IF is better) ....................................................................................................... 10
Letter Grade (TRUE, approximate match) ................................................................................ 11
Choose Employee (validation lists) ........................................................................................... 12
Fill in a Blank (ifna) .................................................................................................................... 13
Bonus Exercise ............................................................................................................................... 14

Pandora Rose Cowart


Education/Training Specialist II
Educational Technologies, UF Health IT Training

E-206, Professional Park (352) 273-5051


PO Box 100002 [email protected]
Gainesville, FL 32610-0002 http://training.health.ufl.edu

Class Evaluation: https://go.ufl.edu/trainingeval

Updated: 9/14/2023
VLOOKUP Worksheet Function
From Office Help
Description
You can use the VLOOKUP function to search the first column of a range of cells, and then return a value
from any cell on the same row of the range. For example, suppose that you have a list of employees
contained in the range A2:C10. The employees' ID numbers are stored in the first column of the range,
as shown in the following illustration.

If you know the employee's ID number, you can use the VLOOKUP function to return either the
department or the name of that employee. To obtain the name of employee number 38, you can use
the formula =VLOOKUP(38, A2:C10, 3, FALSE). This formula searches for the value 38 in the first column
of the range A2:C10, and then returns the value that is contained in the third column of the range and
on the same row as the lookup value ("Axel Delgado").

The V in VLOOKUP stands for vertical. Use VLOOKUP instead of HLOOKUP when your comparison values
are located in a column to the left of the data that you want to find.

Remarks
• When searching text values in the first column of table_array, ensure that the data in the first
column of table_array does not contain leading spaces, trailing spaces, inconsistent use of
straight ( ' or " ) and curly ( ‘ or “) quotation marks, or nonprinting characters. In these cases,
VLOOKUP might return an incorrect or unexpected value. You may be able to use the CLEAN
and/or TRIM function to reformat your data.

• When searching number or date values, ensure that the data in the first column of table_array
is not stored as text values. In this case, VLOOKUP might return an incorrect or unexpected
value.

• If range_lookup is FALSE and lookup_value is text, you can use the wildcard characters — the
question mark (?) and asterisk (*) — in lookup_value. A question mark matches any single
character; an asterisk matches any sequence of characters. If you want to find an actual
question mark or asterisk, type a tilde (~) preceding the character.

Syntax: VLOOKUP( )
VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])

Page 3
The VLOOKUP function syntax has the following arguments:

• lookup_value Required. The value to search in the first column of the table or range. The
lookup_value argument can be a value or a reference. If the value you supply for the
lookup_value argument is smaller than the smallest value in the first column of the table_array
argument, VLOOKUP returns the #N/A error value.

• table_array Required. The range of cells that contains the data. You can use a reference to a
range (for example, A2:D8), or a range name. The values in the first column of table_array are
the values searched by lookup_value. These values can be text, numbers, or logical values.
Uppercase and lowercase texts are equivalent.

• col_index_num Required. The column number in the table_array argument from which the
matching value must be returned. A col_index_num argument of 1 returns the value in the first
column in table_array; a col_index_num of 2 returns the value in the second column in
table_array, and so on.

• If the col_index_num is less than 1, VLOOKUP returns the #VALUE! error value.

• If the col_index_num is greater than the number of columns in table_array, VLOOKUP


returns the #REF! error value.

• range_lookup Optional. A logical value that specifies whether you want VLOOKUP to find an
exact match or an approximate match:

• If range_lookup is either TRUE or is omitted, an exact or approximate match is returned. If


an exact match is not found, the next largest value that is less than lookup_value is
returned.

• If range_lookup is either TRUE or is omitted, the values in the first column of table_array
must be placed in ascending sort order; otherwise, VLOOKUP might not return the correct
value.

• If range_lookup is FALSE, the values in the first column of table_array do not need to be
sorted.

• If the range_lookup argument is FALSE, VLOOKUP will find only an exact match. If there are
two or more values in the first column of table_array that match the lookup_value, the first
value found is used. If an exact match is not found, the error value #N/A is returned.

VLOOKUP( ) =VLOOKUP(B11, Items, 2, FALSE)


Find Item from cell B11 B11
Look in Range "Items" Items
Return column 2 2
Find closest #? No, find exact False

Page 4
Data Validation: Insert or delete a drop-down list
From Office Help

To make data entry easier in Excel, or to limit entries to certain items that
you define, you can create a drop-down list of valid entries that is
compiled from cells elsewhere in the workbook. When you create a drop-
down list for a cell, it displays an arrow in that cell. To enter information in
that cell, click the arrow, and then click the entry that you want.

To create a drop-down list from a range of cells, use the Data Validation command in the Data Tools
group on the Data tab.

1. To create a list of valid entries for the drop-down list, type the entries in a single column or row
without blank cells.
For example:
A
1 Sales
2 Finance
3 R&D
NOTE : You may want to sort the data in the order that you want it to appear in the drop-down list.
2. If you want to use another worksheet, type the list on that worksheet, and then define a name for
the list.
3. Select the cell where you want the drop-down list.
4. On the Data tab, in the Data Tools group, click Data Validation.

5. In the Data Validation dialog box, click the Settings tab.


6. In the Allow box, click List.
7. To specify the location of the list of valid entries, do one of the following:

• If the list is in the current worksheet, enter a reference to your list in the Source box.
• If the list is on a different worksheet, enter the name that you defined for your list in the
Source box.

In both cases, make sure that the reference or name is preceded with an equal sign (=). For
example, enter =ValidDepts.
8. Make sure that the In-cell dropdown check box is selected.
9. To specify whether the cell can be left blank, select or clear the Ignore blank check box.

Page 5
IF Worksheet Function
From Office Help
Specifies a logical test to perform

Syntax: IF( )
IF(logical_test, value_if_true, value_if_false)
• Logical_test is any value or expression that can be evaluated to TRUE or FALSE. For example,
A10=100 is a logical expression; if the value in cell A10 is equal to 100, the expression evaluates
to TRUE. Otherwise, the expression evaluates to FALSE. This argument can use any comparison
calculation operator.
• Value_if_true is the value that is returned if logical_test is TRUE. For example, if this argument is
the text string "Within budget" and the logical_test argument evaluates to TRUE, then the IF
function displays the text "Within budget". If logical_test is TRUE and value_if_true is blank, this
argument returns 0 (zero). To display the word TRUE, use the logical value TRUE for this
argument. Value_if_true can be another formula.
• Value_if_false is the value that is returned if logical_test is FALSE. For example, if this argument
is the text string "Over budget" and the logical_test argument evaluates to FALSE, then the IF
function displays the text "Over budget". If logical_test is FALSE and value_if_false is omitted,
(that is, after value_if_true, there is no comma), then the logical value FALSE is returned. If
logical_test is FALSE and value_if_false is blank (that is, after value_if_true, there is a comma
followed by the closing parenthesis), then the value 0 (zero) is returned. Value_if_false can be
another formula.
Remarks
• Up to seven IF functions can be nested as value_if_true and value_if_false arguments to
construct more elaborate tests.
• When the value_if_true and value_if_false arguments are evaluated, IF returns the value
returned by those statements.

=IF(A10<=100, "Within budget", "Over budget")


=IF(A10=100, SUM(B5:B15), "")
=IF(B2>C2, "Over Budget", "OK")
=IF(B3>C3, "Over Budget", "OK")

Logic Tree
Logical Test

If True If False

Page 6
IS Worksheet Functions
From Office Help

Description
Each of these functions, referred to collectively as the IS functions, checks the specified value and
returns TRUE or FALSE depending on the outcome. For example, the ISBLANK function returns the
logical value TRUE if the value argument is a reference to an empty cell; otherwise it returns FALSE.

You can use an IS function to get information about a value before performing a calculation or other
action with it. For example, you can use the ISERROR function in conjunction with the IF function to
perform a different action if an error occurs:
=IF(ISERROR(A1), "An error occurred.", A1 * 2)

This formula checks to see if an error condition exists in A1. If so, the IF function returns the message
"An error occurred." If no error exists, the IF function performs the calculation A1*2.

Syntax: IS( )
The IS function syntax has the following argument:

• Value ‐Required. The value that you want tested. The value argument can be a blank (empty
cell), error, logical value, text, number, or reference value, or a name referring to any of these.

FUNCTION RETURNS TRUE IF


ISBLANK Value refers to an empty cell.
ISERR Value refers to any error value except #N/A.
ISERROR Value refers to any error value (#N/A, #VALUE!, #REF!,
#DIV/0!, #NUM!, #NAME?, or #NULL!).
ISLOGICAL Value refers to a logical value.
ISNA Value refers to the #N/A (value not available) error value.
ISNONTEXT Value refers to any item that is not text. (Note that this
function returns TRUE if the value refers to a blank cell.)
ISNUMBER Value refers to a number.
ISREF Value refers to a reference.
ISTEXT Value refers to text.
Remarks
• The value arguments of the IS functions are not converted. Any numeric values that are
enclosed in double quotation marks are treated as text. For example, in most other functions
where a number is required, the text value "19" is converted to the number 19. However, in the
formula ISNUMBER("19"), "19" is not converted from a text value to a number value, and the
ISNUMBER function returns FALSE.

• The IS functions are useful in formulas for testing the outcome of a calculation. When
combined with the IF function, these functions provide a method for locating errors in
formulas.

Page 7
IFNA Worksheet Function
Note from Pandora
From Office Help
This function will not work in Excel 2010 and earlier, so if you are using an
older version of Excel you can use the IF(ISNA(), T, F) option to get the
Description
same result.
The IFNA function returns the
value you specify if a formula IF(ISNA(VLOOKUP(B3, Data, 3, FALSE)), "", VLOOKUP(B3, Data, 3, FALSE))
returns the #N/A error value;
otherwise it returns the result IFNA(VLOOKUP(B3, Data, 3, FALSE), "")
of the formula.

Syntax IFNA
IFNA(value, value_if_na)

The IFNA function syntax has the following arguments.

Argument Description
Value
The argument that is checked for the #N/A error value.
Required
value_if_na
The value to return if the formula evaluates to the #N/A error value.
Required

Remarks
If value or value_if_na is an empty cell, IFNA treats it as an empty string value ("").

If value is an array formula, IFNA returns an array of results for each pcell in the range specified in value.

IFERROR Worksheet Function


From Office Help

Description
You can use the IFERROR function to trap and handle errors in a formula. IFERROR returns a
value you specify if a formula evaluates to an error; otherwise, it returns the result of the
formula.

Syntax
IFERROR(value, value_if_error)

The IFERROR function syntax has the following arguments:

Argument Description
Value
The argument that is checked for an error.
Required
value_if_error The value to return if the formula evaluates to an error. The following error
Required types are valuated: #N/A, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME?, or #NULL!.

Remarks
If value or value_if_error is an empty cell, IFERROR treats it as an empty string value ("").

If value is an array formula, IFERROR returns an array of results for each cell in the range specified in
value. See the second example below.

Page 8
Class Exercises
Phone Lookup (vLookup)
A B C D

1 Original Data
2 Name Employee ID Title Phone #
3 Scrooge McDuck 2134-6113 Captain (352) 555-2060
4 Donald Duck 3291-5756 First Mate (352) 555-6108
5 Daisy Duck 9949-3960 Quartermaster (352) 555-6615
6 Gus Goose
1 2
6670-5237 Gunner 3 (352) 555-1387
4
7 Huey Duck 5602-6973 Cabin Boy (352) 555-5025
8 Louie Duck 7362-1089 Cabin Boy (352) 555-8546
9 Dewey Duck 1910-3921 Cabin Boy (352) 555-6756

VLOOKUP( lookup_value, table_array, col_index_num, [range_lookup] )


VLOOKUP( Find this value, in this dataset, return data from column #, FALSE (exact match) )

F G

1 Phone Lookup
2 Name Phone #
3 Daisy Duck =VLOOKUP( F3, A3:D9, 4, FALSE )
4 Dewey Duck

Lock the Range


Cell addresses in an equation are relative to their location. When we use the fill handle or copy and
paste feature the addresses move to the new location. When we fill the equation above to the next row,
the formula will become:

=VLOOKUP( F4, A4:D10, 4, FALSE )


We want the first value to change, so we're now looking for "Dewey Duck", but we need the data range
to stay the same. The two options we learn in the Basic 2: Math class are locking the cell addresses and
naming the range.

To Lock a range, you can type in the dollar signs (little handcuffs), or you can press function key F4 as
soon as you select the range and Excel will add the dollar signs for you. F4- Force!

=VLOOKUP( F3, $A$3:$D$9, 4, FALSE )


You need to Name a range before you start your equation. Select the data range, click in the name box
and type the name you want for that dataset and press Enter on the keyboard. I used the name Data.

=VLOOKUP( F3, Data, 4, FALSE )


Page 9
Title Lookup (vLookup)

A B

1 Title Lookup
2 Name Title
3 Daisy Duck =VLOOKUP( A3, Data, 3, FALSE )
4 Dewey Duck Cabin Boy
5 Donald Duck First Mate
6 Gus Goose Gunner

Use function key F3 to open the name box while you're building an equation. F3- Find Me!

PayRate (when IF is better)

Once you unlock the pattern of a vLookup, it might be


tempting to use it all the time. This PayRate example
that we used in the Math 3: Logic and Ifs class doesn't
work well with a vLookup.

=VLOOKUP(A2, $G$2:$H$3, 2, FALSE)

vs.

=if(A2="Boots", 16, 14)

In this case the #N/A error occurs because the table in G:H does not contain the other shoes. No Flip
Flops, no Sandals, no Sneakers. Use the IF statement or add the missing values to the table.

Page 10
Letter Grade (TRUE, approximate match)
The IF statement we created in the Math 3: Logic and Ifs class became a little complicated.

If( Grade >= 90 )

A If( Grade >= 80 )

B If( Grade >= 70 )

C If( Grade >= 60 )

D F

=IF(A2>=90, "A", IF(A2>=80, "B", IF(A2>=70, "C", IF(A2>=60, "D", "F"))))

Like the PayRate example I don't have every value listed, however this is based on numbers not text.
And we can use the TRUE as the last value in our vLookup to find the closest value.

To Lookup the closest numbers, they must be in Ascending (lowest to highest) order. If Everyone is
failing, resort your Grades.

=VLOOKUP(A2, $D$4:$E$8, 2, TRUE)

Page 11
Choose Employee (validation lists)

A B

1 Choose Employee
2

3 Do they like cake? Yes


4

5 Employee: Daisy Duck

6 Title: =VLOOKUP( B5, Data, 3, FALSE )

We can build a list within a cell using the Data Validation


tool on the Data tab.

Change the Allow option to List, and type in the values, or


=the named range, or select a single column of the values
you want to appear on the list.

If you type in a defined name, such as NAMELIST, be sure to put the equal sign in the front. Remember
you can use the function key F3 to choose from a list of names.

The named range or selection of cells must be for a single row or column of data.

Choose a name from cell B5 and build the vLookup in cell B6. Remember, we named the search table
"Data" and Title was in the third column of "Data".

=VLOOKUP(B5, Data, 3, FALSE)

Page 12
Fill in a Blank (ifna)

A B C

1 Fill in a Blank
2 Employee Name Employee Title

3 #1: Daisy Duck =VLOOKUP( A3, Data, 3, FALSE )


4 #2: #N/A
5 #3: Louie Duck Cabin Boy

Since there is no Employee 2 listed, we get the #N/A message saying the vLookup can't find that value.

There are a few choices to deal with this.

1) Ignore it. I often do, I know what it means. I can use it to filter all the unmatched data.

2) Use Conditional Formatting (on the Home tab) to make the text appear invisible by turning the
font color white.

3) Use a nested formula with IF and ISNA.

Question: Does our vLookup return an N/A


If TRUE: If it's true, let's put a blank cell ""
If FALSE: show me what the vLookup returned

=IF( ISNA( VLOOKUP( A3, Data, 3, FALSE ) ), "", VLOOKUP( A3, Data, 3, FALSE ) )

4) Use the IFNA function

=IFNA(VLOOKUP( A3, Data, 3, FALSE ), "")

Page 13
Bonus Exercise

Step 1: Name the list of Names


- Sheet "Shipping Addresses"
- Select Column A
- In the Name box, type NameList, press enter

Step 2: Name the Addresses Range


- Sheet "Shipping Addresses"
- Select Columns A:D
- In the Name box, type Addresses, press enter

Step 3: Name the List of Items


- Sheet "Sales Items"
- Select Column A
- In the Name box, type ItemList, press enter

Step 4: Name the Items Range


- Sheet "Sales Items"
- Select Columns A:B
- In the Name box, type Items, press enter

Page 14
Step 5: Set up Name List
- Sheet "Sales Invoice", Cell C5
- Data Tab, Data Validation
- Allow: List
- Source: =NameList (don't forget the = sign)

Step 6: Set up Address Lookups


- Sheet "Sales Invoice"
VLOOKUP( ) C6 C7 C8
Find Name from cell C5 C5 C5 C5
Look in Range "Addresses" Addresses Addresses Addresses
Return column 2, 3, 4 2 3 4
Find closest # No, find exact False False False

- C6: =VLOOKUP(C5, Addresses,2, FALSE)


- C7: =VLOOKUP(C5, Addresses,3, FALSE)
- C8: =VLOOKUP(C5, Addresses,4, FALSE)

Page 15
Step 7: Set up Item List
- Sheet "Sales Invoice", Cell B11
- Data Tab, Data Validation
- Allow: List
- Source: =ItemList (don't forget the =)

- Copy/Fill formula down through Row 17

Step 8: Set up Price Lookups


- Sheet "Sales Invoice"

VLOOKUP( ) C11
Find Item from cell B11 B11
Look in Range "Items" Items
Return column 2 2
Find closest # No, find exact False

- C11: =VLOOKUP(B11, Items,2, FALSE)

Page 16
Step 9: Change equation to hide #N/A
IF Lookup =#N/A

T F

"" Lookup

Logical Test Is the vLookup #N/A? ISNA(VLOOKUP(B11,Items,2,FALSE))


If True Leave blank ""
If False Do the vLookup VLOOKUP(B11,Items,2,FALSE)

- C11: IFNA(VLOOKUP(B11, Items,2, FALSE), "")


- ~OR~ C11: =IF(ISNA(VLOOKUP(B11, Items,2, FALSE)),"", VLOOKUP(B11, Items,2, FALSE))

- Copy/Fill equation down to C17

Step 10: Set Subtotal equation


- Sheet "Sales Invoice"
- E11: =C11*D11

Step 11: Change equation to hide


- Change equation to account for blanks
IF Item = ""

T F

"" Calculate subtotal

Logical Test Is the Item blank? C11=""


If True Leave blank ""
If False Calculate SubTotal C11*D11

- E11: =IF(C11="","", C11*D11)

Page 17

You might also like