Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

The VLOOKUP Function in Excel 2000

The VLOOKUP function in Excel provides a way to set up a table of values within a spreadsheet, and then have Excel find a value from that table and insert it into a given place on your spreadsheet. This handout assumes you have basic knowledge of using Excel 2000. If not, consult our other handout, Using Excel 2000 first. For example, you may want to set up a spreadsheet of student grades. You would like to have the final grades appear next to each student's name based on your grade scale. Using VLOOKUP, you can have Excel display a letter grade in one column of your spreadsheet based on the student's final grade in another column. For VLOOKUP to work, in addition to the student scores already in the spreadsheet, you must also create a table within the same spreadsheet indicating your scale for the grades. VLOOKUP "looks up" this table and returns the final grade to the column you have specified. Let's say you have the following spreadsheet of student grades:

In the column labeled Final Grade you want to have Excel place a final letter grade. In order to do this, you must first set up a "lookup table," which is the table Excel will use to generate a value in the column for Final Grade. This is relatively easy to do, but the following must first be taken into account: For your lookup table, you want to place the value you want to look up (in this case, the final grade percentage) in one column, and the value you want displayed (in this case, the letter grade) in a separate column next to the corresponding value that is being looked up. The column of lookup values must be placed in ascending order. Excel will first try to find an exact match in your lookup table. If it finds one, it returns the item you specify next to that lookup value. If it does not find an exact match, it returns the item from the next lowest number on your lookup table. Looking at some examples best shows this.

2 For our spreadsheet, let's use a simple grade scale: 90 - 100% A 80 - 89% B 70 - 79% C 60 - 69% D Below 60% F Here is what our lookup table will look like in the spreadsheet:

Remember, this must appear somewhere on our worksheet that we are using--it does not really matter where. Also, remember that the lookup numbers on a VLOOKUP table must be in ascending order, which in this case is the opposite of the way we usually think of a grade scale. So, they are from the lowest percentage to the highest. To better visualize things, here is what the entire spreadsheet looks like so far:

Here is our student grade data that gives the final percentage the student has earned in class. Here is the newly created lookup table that the VLOOKUP function requires to work. (The title in cell A11 is not required; all VLOOKUP needs for this spreadsheet is the data in cells A12 through B16.)

VLOOKUP Function in Excel

3 When setting up a lookup table, keep in mind that Excel looks for an exact match first, then failing that will return the corresponding value from the next lowest number. This is why many VLOOKUP tables start at zero. For example, let's say a student gets a final grade of 71%. Excel will try to find an exact match for 71% in the above table. There is no exact match. So, Excel will then go to the next lowest number on the table--in this case, 70%. Next to 70% is the grade of C, which is the grade Excel will record on your spreadsheet. So, the student with 71% will get a grade of C--which is exactly what the grade should be based on our grade scale. Once you've established a lookup table, you're ready to do the VLOOKUP function itself. As is the case with any other formula or function in Excel, you want to place your cursor in the cell where you want the formula results to appear. In the case of our sample spreadsheet on the previous page, that would be within cell C3. Then, click the Paste Function button on the Excel toolbar: Next, go to the Lookup & Reference category in the Paste Function dialog box, click on VLOOKUP, and click OK:

You will then get the following function palette:

VLOOKUP Function in Excel

4 Like other function palettes, the required fields are in bold face type. First, in the Lookup_value box, you need to specify the cell that you want Excel to "lookup" as part of this function. Do not confuse this with the lookup table, which is the next box down. Given that we are putting our function's formula in cell C3, this means we want Excel to look at the percentage (final grade percentage) we have in cell B3. (Refer to the spreadsheet on page 1.). Therefore, we can type B3 in that box. Next, we have to specify the Table_array. This means the cells where our lookup table was placed within our spreadsheet. Notice that there is a "collapse dialog box" to the right of each of these windows in this function palette, so if this function palette is in the way, click the "collapse dialog box" and just click and drag over the cells where your lookup table was placed. Here is what it should look like after this step:
Remember to click on a "collapse dialog box" icon if the function palette gets in your way.

Be careful that you do not include any extraneous text when you tell Excel where your lookup table is. Click and drag only over the cells with the numbers and the data--not text. In this case, we were careful not to include our lookup table text of "Table for Grades" within the cell range. Also, remember the same rules for copying formulas and functions apply here, too--we want to make this table array an absolute reference so that when we copy the function formula down a column, Excel won't change the cell values for where this table is. Therefore, the final step in the Table_array window is pressing the F4 function key on the keyboard to turn all cell references into an absolute address:

VLOOKUP Function in Excel

5 Finally, we need to specify the Col_index_num--which means "column index number." In other words, in this lookup table, which column contains the value we want returned to the spreadsheet? Please note this does not mean the column on the spreadsheet itself (such as column A, B, C, D, etc.), but rather a column number within the lookup table itself, starting from the left. In most cases, you will be typing the number 2 here--since your values will usually be in the second column from the left:

Finally, you can click the OK button, and check out the first result on your spreadsheet:

Notice that student Boris Badenov--who had a final percentage of 59%--indeed gets an "F" as his final grade based on the VLOOKUP function. (Note in the screenshot above what the formula bar looks like when your cursor is in a cell that contains a VLOOKUP. Like other functions, it starts with the function name, with the rest in parentheses.)

VLOOKUP Function in Excel

6 The final step is copying the formula down the column as you ordinarily would:

Once copied down, notice that the final grades all correspond to the way we intended, based on our lookup table:

Other uses for VLOOKUP could include a tax table. For example, say you have to indicate on your spreadsheet the taxes that are paid based on the following information: Salary Up to $14,999 15000 - 24,999 25,000 - 39,999 $40,000 and above Tax Rate 3% 4% 5% 6%

VLOOKUP Function in Excel

7 You can incorporate this information into the following type of spreadsheet:

Taking into account the "rules" for creating a lookup table, we can then create a tax lookup table elsewhere in this same spreadsheet. Remember, you want the lowest values for each range in a lookup table. Here is what our spreadsheet now looks like with the addition of a lookup table:

Here is the original data in our spreadsheet.

Here is the lookup table that must be created for VLOOKUP to work. The title in cell B11 is only for our own reference--it is not required for VLOOKUP to work, and in fact must be ignored when using the VLOOKUP function.

VLOOKUP Function in Excel

8 Next, we position our cursor in cell C3 (again, where we want our first formula results to appear), click the paste function button, and select VLOOKUP. Here is what the function palette will look like when completed:

Note the column index is 2--even though our lookup table is in columns B and C of our spreadsheet. Location of the lookup table in this window is not important; what is important is where the data is placed in the lookup table!

Remember to press F4 to make your table array an absolute reference!

Looking at the Formula result at the bottom of this function palette, we see that the result will be 0.04. This is what it should be for Boris Badenov, who, based on our tax table, should be paying a 4% tax rate. Therefore, we click OK and copy the formula down:

VLOOKUP Function in Excel

9 We are not quite finished yet, however. The percentages are correct, but we want the actual tax paid to be shown in the Tax paid column, not just the rate. So, place the cursor back in cell C3, where we created our formula. We can now edit our VLOOKUP formula so that the results are multiplied by the annual salary (cell B3) in our example, using the regular symbol (*) for multiplication. We can do this directly in the formula bar. Here is what our revised formula will look like in Excel:

The formula bar now shows: VLOOKUP(B3,$B$13:$C$16,2)*B3 It has the original VLOOKUP formula we just completed, only we manually added the *B3 in order to multiply our VLOOKUP formula result (the tax rate) by the annual salary in B3. After pressing ENTER (or clicking the check mark in the formula bar) to complete the formula, we copy our new formula down the column:

VLOOKUP Function in Excel

10 All we have to do now is select the cells with the mouse and convert them to the currency format by clicking the button in the formatting toolbar ( ), and we're done!

Revised May 2001 by Ken Black

VLOOKUP Function in Excel

You might also like