LOOKUP FUNCTIONS IN EXCEL 2007 Lookup tables can be used to hold various types of fixed information that can be “looked up” from another part of the worksheet, e.g. rates of pay, credit ratings, addresses etc. If you want to practice using a spreadsheet you can do so by completing the following activities. If you would prefer to use the skills on your own spreadsheets read the instructions and apply them to your work. You can use the worksheet Discount to practice these skills. A copy can be found by clicking on the link, Discount. Before using it save it to your user area, computer or external storage device. Columns D to F contain a table to look up customer discounts. The discount is based on the order value from £0 to £10,000 and the type of order (cash or credit). As the discount rates in the table do not follow any obvious numerical sequence, using a formula to generate them would be difficult. You can use two lookup functions to get data from a table: HLOOKUP (Horizontal lookup) is used when the values are arranged horizontally in a row and you ask Excel to look across the row to find the right value. VLOOKUP (Vertical lookup) is used when the values are arranged in a column and you are asking Excel to look down the column to find the right value. Your formula would look like this: =HLOOKUP(x, range, index) or =VLOOKUP(x, range, index). x is the value that you want to look up. It can be entered as text, a number or a cell reference. Range is the range of cells in which Excel will look to find the value. Index tells Excel which column or row to look in. That sounds very complicated. Try the activity and it should all become much clearer. Using LookUp You are going to spend £600 in cash and you are going to try to get a discount on what you buy. 1. Enter 600 in cell C4, which is the “Amount of Purchase” (the amount you are spending) and press the Enter key on your keyboard. 1 2. Now you want to find out how much discount you are going to get for paying for your £600 purchase in cash. 3. In cell C5 enter the formula: =VLOOKUP(C4,D7:F10,2) and press the Enter key on your keyboard. (Ignore all of the other information that pops up on the screen - it is confusing). Explanation of the formula V When you look up the value you want to look across a row, not down a column, so you use V for vertical. Lookup C4 Look up the value in cell C4, (the amount you are spending). D7:F11 Look for it in the table that is in cell range D7 to D10 2 When you have found the nearest figure to 600 in column 1, look in column 2 of the table (the one headed Cash) to find out how much discount the person will be entitled to. The lookup function searches the first column and compares the values in Column D with the value in cell C4 until it reaches a number equal to or higher than 600, in this case it is 1,000. Then it stops looking. It goes back a row to find the nearest amount below the amount it is looking for which is £500.* (see note below). Then it decides which is the closest to the amount it is looking for. In this case it found that 600 was closer to 500 than 1,000. It then goes to the second column as it was told to do and looks up the discount that would be received for spending £500 in cash and has come up with the answer of 0.8. 4. Format the 0.8 as a percentage by clicking the right mouse button on the cell containing 0.8, select the Format Cells option from the drop-down menu. 2 5. In the Format Cells dialogue-box select Percentage from the category list and set it to zero decimal places. You now know that if you spend £600 in cash you will get a discount of 8%. *For this reason the values in a lookup table must be in ascending order. If they are not, when Excel is looking up the values it will stop looking when it comes to the first value that is more than the value it is looking for and then look to see if the value before it is closer. It will then use one of those two values. There may be a value further down the column that is closer to the one it is looking for but it will not find it because it will have stopped looking. You can now use the formula to calculate the amount you have spent (i.e. the purchase value minus the discount). 1. Click in cell B6. 2. Enter the formula: =C4-(C4*C5). 3 3. Press the Enter key on your keyboard. An explanation of what you are asking Excel to do Take the contents of C4 which is the cost of your purchase. Then take away the amount of the discount which is: o 8% of the purchase price, i.e. by multiplying the purchase amount (the contents of C4) by the discount of 8% (the contents of C5) to find the amount of the discount. o Then taking that away from the original purchase price, (the contents of C4). Thus you have asked Excel to find out what the 8% discount amounts to in money terms and take that away from the original amount. Your answer should be 552. Thus you are saving £48 with your discount. Independent activity Use the same spreadsheet to find out what the percentage discount and the final amount is after the discount has been deducted if you spend £600 on credit. You can look at the answer overleaf to check it once you have finished. If you have the money available to do either of these, which would be the most sensible? How much do you save with the discount if you use credit? Discount 5%, amount after discount £570. If you did not get that amount check that your formula was correct. Remember that the cell references will be different as you will put your credit purchase amount in cell C8, and that the discounts for credit are in the third column on the table, not the second. 4