VLOOKUP in Excel

advertisement
Using VLOOKUP in Excel
VLOOKUP is the function to use when you need to find or compare information in a large set of data. The
function looks at a value in one column and finds the corresponding value on the same row in another column.
VLOOKUP Essentials

Use VLOOKUP with lists or tables arranged in vertical columns.

Your lookup_value MUST be in the first or leftmost column. It doesn’t matter physically where the first
column starts: it could start in column A, or it could start in column K. Wherever it starts, the
lookup_value argument must exist in the first column of the list or table. If your lookup table starts at
column R and ends at column T, column R is considered the leftmost column.

To find the column that contains the search result (the col_index_num argument), you literally count,
starting from the left, or first column. For example, if your search result is in column C, the
col_index_num argument would be number 3.

If you leave the range_lookup argument off (which is either True or False), the formula defaults to True.

Use absolute cell references, or a named range, if you copy the formula down a column.
Reference information: VLOOKUP: What it is, and when to use it
**Copy the folder to the desktop of the computer you are working on.
In VLOOKUP Workbook we have the Course ID, Section Name, and
Title and in the second set of data we have the Course ID,
Section Name, Instructor, Term, and Type, however we really need the
information together to use it.
It is important when using VLOOKUP to have a Unique Identifier for
your data and in this case it is the Course ID number.
1. Open the VLOOKUP Workbook and then the Data Set 2
workbook
2.
Let’s copy the worksheet from Data Set 2 into Workbook Data
Set 1
a.
Right-click on the sheet tab of the Data Set 2
b.
Click on Move or Copy
c.
In the Move or Copy dialog box, choose the VLOOKUP Workbook from the “To book:” menu
and check the “Create a copy” check box.
d. Click OK
1
3. On the Data Set 2 worksheet , click in the Course ID column and sort
this column Smallest to Largest
4. On the Data Set 2 worksheet, highlight the data range (A2 – E39)
5. Click in the Name Box and name the range list2 (no spaces)
press Enter on your keyboard
6. Click on the Save Icon (ctrl + s)
7. Highlight the column headings: Instructor, Term and Type
Click Copy or (ctrl + c ) to copy the headings to the clipboard
8. Click on the sheet tab Data set 1
9. Click in Cell D1 and click the Paste button or (ctrl + v)
10. Click in the course ID column and sort Smallest to Largest - Save
11. Click in cell D2 to make it the active cell
12. Click on the Formulas Tab – click on Lookup and Reference – click on VLOOKUP
13. In the Function Arguments dialog box, the Lookup_value is the cell reference that contains the unique
identifier
a. Ours is the Course ID number in cell A2 – type A2 in the Lookup_value text box
b. Make this a absolute column reference by typing a $ before the A
14. The Table_array is set of data that we are looking in for the corresponding information
a. Click in the Table_array text box
b. Press the f3 key on your keyboard to bring up the Paste Names dialog box
c. Select the named range list2 and click OK
15. Col_index_num is the column number where the data I want added to set 1 is located
a. Click into the Col_index_num and type 3
16. Range_lookup is a logical value that specifies whether you want this function to find an exact match or
an approximate match. If TRUE or omitted, an approximate match is returned. If FALSE, this function
will find an exact match. If a match is not found, the error value #N/A is returned.
a. Type FALSE here since we want an exact match
b. Click OK
2
The image below shows the dialog box and the values you should in each Function Argument
17. Using the Fill Handle copy the formula down the column.
You will notice that there are several places where you see the error
message indicating that a match was not found.
If you do not want to see that error message you can use the IFERROR
function along with the VLOOKUP function
18. Click into cell D2 to make it the active cell, then click into the formula bar and add the IFERROR
function
19. Your formula should look like this
20. Scroll back up to the top of the spread sheet and click into cell D2, click the fill handle and copy the
formula into cell E2
21. Click into the formula bar, change the “3” to a “4”
22. Copy to the rest of the column
23. Copy the formula in cell E2 into cell F2 change the “4” to a
“5”and copy down the column.
3
Example # 2: Band Members and Scholarships
Click on the sheet tab named Band Members 2014 and scroll down to the end of the names or click in
cell A1 and press the control key and the down arrow to get to the last entry in column A. Make a
mental note that there are 104 students and total Scholarship amount is $492,040.00.
Open the Band Members Scholarships spreadsheet and let’s check the figures the secretary sent to you.
Something is wrong! We only have 100 students and the total does not match.
1. Copy the Band Members scholarships spreadsheet into the VLOOKUP workbook
2. Sort the data by the ID Number – smallest to largest
Let’s name the range of data bandlist2 to make it easier when we make our formula
3. Click in the Name Box and type bandlist2 and click Enter on your keyboard, click Save
4. Make a mental note that the information that you are going to compare is in column 6
5. Click on the sheet tab Band Members 2014 and repeat the sort, so that the ID Number column is sorted
smallest to largest.
6. Click into cell L2
7. Click on the Formulas tab and click on VLOOKUP under Lookup & Reference
1. In the Function Arguments dialog box, the Lookup_value is the cell reference that contains the
unique identifier
a. Ours is the Course ID number in cell A2 – type $A2 in the Lookup_value text box
2. The Table_array is set of data that we are looking in for the corresponding information
a. Click in the Table_array text box
b. Press the f3 key on your keyboard to bring up the Paste Names dialog box
c. Select the named range bandlist2 and click OK
3. Col_index_num is the column number where the data I want to check is located
a. Click into the Col_index_num and type 6
4. Range_lookup is a logical value that specifies whether you want this function to find an exact match
or an approximate match. If TRUE or omitted, an approximate match is returned. If FALSE, this
function will find an exact match.If one is not found, the error value #N/A is returned.
a. Type FALSE here since we want an exact match
b. Click OK
4
As you scroll down you can now see who is missing from your
Scholarship list but it is difficult to compare the amounts to see what
ones are incorrect.
Let’s use Conditional Formatting to highlight the cells that do not
match
1. Highlight the data in your compare column (column L)
2. Click on the Home Tab – click on Conditional Formatting – click
on Highlight Cells Rules – click on More Rules
3. In the New Formatting Rule dialog box select
“Use a formula to determine which cells to format”
4. In the “Format values where this formula is true:”
text box, type the formula L2< >J2 (No Spaces)
5. Click on the Format button and choose a color
6. Click OK and OK
We are going to have to edit this formula before we copy it.
7. Click on Conditional Formatting – Manage Rules
8. Select the rule and click Edit Rule
9. Remove the quotes from around the formula
10. Click OK
11. Click Apply and OK
5
References and Resources
Quick Reference Card
http://officeimg.vo.msecnd.net/en-us/files/818/530/AF101984660.pdf
Microsoft Office Training Course
http://office.microsoft.com/en-us/excel-help/vlookup-what-it-is-and-when-to-use-it-RZ101862716.aspx?CTT=1
Microsoft Office Blogs
http://blogs.office.com/
Compare Values in different Excel Worksheets
http://www.youtube.com/watch?v=HSIX7Hg3bxQ
How to Combine 2 Excel Workbooks Using VLOOKUP
http://www.youtube.com/watch?v=809m6kLTfgI
6
Download