0% found this document useful (0 votes)
22 views5 pages

Excel 6

look up tables

Uploaded by

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

Excel 6

look up tables

Uploaded by

rafo_peru
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 5
LOOKUP TABLES (Using VLOOKUP as example) The functions VLOOKUP and HLOOKUP enter information into a spreadsheet from a table made up of possible values. The result can be a value or text. The advantages of using VLOOKUP and HLOOKUP are: ‘+ They avoid the need for repetitious data; * Cuts down on the possibility of entering data incorrectly; and * Allows automatic updating of entries by changing the values in the lookup table. Example: Imagine having to work out staff allowances for 100 staff, each entitled to a return airfare to their home town each year. If you enter a value next to each staff member for the price of the airfare, and the airfares change (as they do), you would have to change each value every time the airfares changes. By using VLOOKUP, only the airfares in the lookup table are updated. @ tam Eo Smih, Fred Mslooume Figure 1 - Airfares entered manually ip.ixws, Tom [Darwin EI 7 Brown. doin Meleoume 230.00 8 Tremaon, len Adele 400 0 2 Ptchas, Polat Addico 400.00 “Winer, Vale Dawn 75 00 11 Hams, Thomas Poth 20.0 12 Reserson, Sch Keka 3500 1G Roe, Dense Path e000 cs 4 eadoaines ceeaienrase rigure2-airtarss | 1\VLOOKL ti tamgavioonu |) formula — if the 2 3 airfares change | 2 ame Home Twn ie om Ae thon onlythe | 5S rea Maen" SUB Bas Yc amount in Sie ie Com Se Ae SotommHwit be? Bm) tleine 60D Sun So " & thn een Mie — Bt awa” changed =the | pied Caer Sede EID coe So ecto — Gem Moore 2000 ‘column C will 11 Harts, Thomas Penh e000 Perth 90.00, Update Te uberom Sah rebre 5000 Sitter 200 automatically, [Shoe tense” San! Soar Modulos\Advanced ExcaiAavanced Excel formulas and funetone oe LOOKUP function (see Figure 2), looks up a value from the LEFT most column of a table. This function is used when your data is arranged in columns. HLOOKUP function looks up a value from the top row of a table. HLOOKUP is used when your table is arranged in rows. Syntax: VLOOKUP(lookup_value,table_array,col_index_num,range_lookup) HLOOKUP(lookup_value,table_array,row_index_num,range_lookup) The bold part of the formula above is required, the last bit is optional lookup_value _refers to a cell in the main part of your worksheet whose information also appears in the first column (or row if using HLOOKUP) of your table. Using Figure 2 as an example, the lookup value for the first staff member is cell BS (Melbourne). This information is also found in the first column of the Lookup table (the table you are going to refer to, to get the amount of the airfare). The lookup value can be text, a value or a cell reference. table_array refers to the reference table from which you are going to get information. When referring to this table you should refer to an ABSOLUTE range (in Figure 2 the table's range is $G$5:$H$12). You can also refer to a Range Name. If you give the table a range name, by default the cells will be absolute. Having an absolute range ensures that the formula always refers to the same set of cells making up the table when copying. The first column (oF first row) of the table can be text, numbers or logical values. It doesn't matter if it is uppercase or lowercase. The first column (or row) should be in either numerical or alphabetical order, it can be sorted using the DATA, SORT menu col_index_num The third part of the function is asking which column of the reference table do you want your answer to come from. In Figure 2 the table is a 2-column table and we want the answer to be the amount of the airfare, therefore in this case the col_index_num would be 2. If the col_index_num is less than 1, you will get a #VALUE error. = If col_index_num is more than the number of columns in the table, you will get a #REF! error. range_lookup The 4th part of the formula is optional depending on the answer you want. If you require an exact match, use FALSE. If you want an approximate match, leave this option out or use TRUE (they are the same) For example (refer to Figure 3), Denise Roe’s home town has been changed from Perth to Deniliquin. The fourth part of the LOOKUP function has been made to say TRUE and will therefore look up an approximate match. Deniliquin is not in the table of airfares therefore the formula retums the nearest match which is less than or equal to what is being looked up (Deniliquin). Darwin is the nearest match, ‘Sdminisatvelstormation Technalogy Customer Senioes ManagementEaucaton and Training TeeriGurent Tranng Page Modulos\Advanced ExcaiAavanced Excel formulas and funetone oe slightly lower in the alphabetical scale. This formula would be unsuitable in this case because hopefully the airfare to Deniliquin would be nowhere near the amount of $799.00. FALSE should have been used in the fourth part of this function. wage fe SLODKUP(ES 8354 SHEI2 2. TELE) a a a a ome Tow Aare olsun [zo Vowes.Tart Darvin, a0 rstane 7 [Ben Joba Metbouna—|—230.00, (enbere ‘Thomann — Adelaide | A000 Darn © Prtenag, Peer Ausiave 40000 Hout ‘te, vale asin mau bourne 1 ae, Thomas Pet eon eh 12 everson, Sanh Heban 0.00 ‘Sydney H13|foe, Oana Deniquin | 70200, Figure 3 - Finding an Approximate Match NOTES: When TRUE is used, or the range_lookup is omitted, the VLOOKUP and HLOOKUP will return the largest match which is less than or equal to the lookup_value. * fusing FALSE and exact match is not found, a #N/A error is returned. + Iflookup_value is smaller than the smallest value in the first columnirow of the table, you will get a #N/A error. + When referring to the table range, the range should be made to be ; ABSOLUTE. i.e. highlight the table (do not include headings), press F4 until the range has “S” signs in front of column and row references e.g. $G$5:$H$12. (Fé is the shortcut key to toggle between different sorts of addresses — relative, absolute and a combination of the two. Away to remember this shortcut key is that the normal number 4 has the $ sign above it) * Consider giving the table a range name. Using the airfare example, a good name would be “Airfares. As a default range names are made absolute, See pages 7 to 9 on how to name ranges. ‘+ The table can be put on the same worksheet as your data however you should take into account security issues. If you don’t want just anyone changing the core data of the table you might wish to put the table on a different worksheet or even in a totally different file. See Pages 12 to 13 for instructions on how to reference other worksheets or files, ‘SAdministatvelsormation Techaalogy/ Gustomer Sewees Managementeaucaton and Training TeariGuvrent Trang Page 82 Modulos\Advanced ExcaiAavanced Excel formulas and funetone oe Creating the VLOOKUP Function To practice the VLOOKUP formula, open the read-only file Advanced Excel Exercises and go to the VLOOKUPS worksheet. Use the FILE, SAVE AS command to save this file in a different name in your P:\DATA folder. elem eit coen an 1 2 3 2 Name Hone oven Adan [Sith red albeune 8 ones. Ton Dats 7 Brow, Jem alteune Thomson, Heian Ada 3 Pricha, Pete Adelaide 10 Primer, Valera Daren 11 Hates, Taemae Peek 12 Robaieon, Sarah Heban 13 Roe, Dene Deniquin 1. Place your cursor in the cell where the first result will be (C5 using the example above) 2. Use the instructions on Pages 2 to 5 to get the VLOOKUP FUNCTION ARGUMENTS dialog box showing on your Excel worksheet. 3. The Lookup_value is asking you to refer to a cell in the main part of your worksheet, that has the data that also appears in the first column of the reference table. Using our airfare example, B5 has this information, B5 has the text "Melbourne". Melbourne also appears in the first column of our reference table. If you can see BS on your spreadsheet, click on it. This cell address will then appear in the first reference. (Use the COLLAPSE DIALOG icon if you can't see the spreadsheet behind the FUNCTION ARGUMENTS dialog box, or move the dialog box by dragging on the title bar). ‘Sdminisatvelniormation Technalogy Customer Sewees Managementeaucaton and Training TeariGuvrent Trang Page 58 Modulos\Advanced ExcaiAavanced Excel formulas and funetone oe 4. Table_array is asking for the details about the table. Highlight the entire table, do not include any headings. When the range address appears in the reference area, use the F4 key to make the range ABSOLUTE (each column and row reference has aS" sign in front of it); or Ifyou have previously given the table a RANGE NAME, use F3 to bring up the PASTE dialog box, select the table name from the list. (See pages 7 to 9 for more about Range Names.) If the table is on another sheet or file, see pages 12 to 13 for Referencing other Sheets or Files. 5. Col_index_num is asking for the number of the column in the table the result is to come from. In our example, the table has only 2 columns and the prices of airfares are in the second column, therefore type the number 2 in the third reference area. 6. Range_lookup is optional (notice the text is not bold like the compulsory arguments). If you want an exact match, type FALSE in here. If you want an approximate match, leave it blank or type TRUE. In our example you would need an exact match. If you are doing the VLOOKUPS exercise, try leaving this option blank and then look at Row 10 and Row 17 of the example. Denise Roe's airfare would read $799.00 - the amount someone flying to Darwin would receive. Joe Bloggs’ airfare would read $400.00. Deniliquin and Alice Springs are not mentioned in the airfares table so it used the nearest matches — Adelaide and Darwin. Fill the option in with “FALSE”. You will now have a “#N/A" error. This will serve to draw your attention to the fact that Alice Springs and Deniliquin both need to be added into the table information. 7. Click on OK to finish the function. If filling several cells with this formula, use the FILL HANDLE to drag down to the other cells. (see Page 14 to read more about the FILL HANDLE) Note: In the example used, NEW STAFF entries should have #N/A errors, As soon as a new staff member and city is added, the prebuilt formula will immediately show the amount of airfare (if the city is mentioned in the table). If you are putting formulas in a worksheet where no data has yet been entered (such as the NEW STAFF in our example) #N/A errors will occur. This type of error can be ‘hidden’ by using the ISNA or ISERROR function. See page 48 for step by step instructions on using this function. If you add new data to the table, your range address used in each formula will have to be changed to include the new cells of the table. If you used a range name this will be taken care of automatically if you ensure that the new data falls within the boundary of the range name — you can check by looking at the reference in the INSERT, NAME, DEFINE dialog box. As a hint, if you add a couple of rows in the middle of the table, add the new data then re-sort the first column of the table into alphabetical/numerical order, the new data will be, confined within the boundaries of the range name. ‘Sdminisatvelniormation Technalogy/ Gustomer Sewees Managementeaucaton and Training TeariGuventTraning Page 84 Modulos\Advanced ExcaiAavanced Excel formulas and funetone oe

You might also like