This action might not be possible to undo. Are you sure you want to continue?

**Excel’s VLOOKUP Function: How to Use It and How to Nest It
**

by Linda Johnson, MOS The VLOOKUP function is a handy one to know when you want Excel to lookup a value in one place and insert it in another. For example, let’s say you have a list of all of your customers on a sheet named “Accounts” and an invoice on another sheet named “Invoice”. When you type in their account number on the Invoice, you want Excel to fill in the name of the customer and their address (and this information is included for all customers on the Accounts sheet). A VLOOKUP will do this for you. Make a small sample workbook to try this out. Name Sheet One “Invoice” and name Sheet Two “Accounts”. On the Accounts sheet, put three columns of data. Column A would be Account Numbers, Column B would be Customer Name, and Column C would be Address. Add at least five pretend customers, so you have enough to play with. On the Invoice sheet, just add these five column headings in cells A1:E1 – Date, Product Ordered, Account #, Customer Name, Address -but don’t put any data in there yet. (In reality, this sheet would be an actual invoice which included sections for you to add ordering info for any products they buy, etc. But for this example, let’s keep it simple.) Now, before we try the VLOOKUP, the best thing to do is name the range of data that includes the info you want to pull over from the Accounts sheet. You can do VLOOKUPs without naming the range, but then you MUST be sure to use absolute cell references. So, I find naming the range a much easier way to do it. Highlight all the data on the Accounts sheet and name it Customers (don’t include the column headings in the named range – just the data). If you don’t know how to name ranges, read this TechTrax article I wrote on how to do that. http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=281 Now that you have your data and have named the range, let’s look at building a simple VLOOKUP formula. Assume we will be typing account numbers into cell C2 and wanting the customer’s name and address to be filled into D2 and E2. The best way to learn new formulas is to use the Insert Function button . In Excel 97 and 2000, it's a button on your Standard Toolbar. In Excel 2002/2003, it's on your Formula Bar. On the Invoice sheet, click into cell D2 and click on the fx button.

(The picture above shows how this box looks in Excel 97/2000. In 2002/2003 it’s slightly different, but I think you can figure it out.) If you know what type of function you are looking for, you can select the category and all the functions within that category will be listed. However, if you don't know what category you need, you can select "All" in the category list and all of Excel's functions will be listed. Notice as you click on any function name, Excel displays a description of what that function does below the boxes. For this exercise, select the "Lookup & Reference" category and scroll down to select the VLOOKUP function. Note that it tells you that this function “searches for a value in the leftmost column of a table and returns a value from the same row in that table based on what column in that row you specify.” Click OK. Once you click OK, you will get the wizard which helps you with your VLOOKUP formula. Now, because we will be typing an Account # in cell C2, that is the value we must put in the first box of this wizard which will tell Excel to look for whatever is in C2 in the leftmost column of our lookup table (which we created on the Accounts sheet and named "Customers"). So, enter C2 into the top box. Click into the next box where it says "Table_array". Notice at the bottom of this box, it tells you what each box you click inside needs. This is where we need to identify our table so Excel knows where to look. So, in this box, simply type Customers. (If you didn’t name the range, you will have to put the absolute reference including the sheet name here … this is why it’s easier to just name the range.) Click into the third box. This one wants to know the number of the column we want returned. Remember that what you entered in the first box in this wizard must ALWAYS be in the first column of your lookup table. So, in our table, the Account # is in the first column and the Customer Name is in the second column. Since the customer name is what we want to put here, just type a 2 to let Excel know we want what is in the second column.

Notice the last box is labeled "Range_lookup" and it is the only label that is not bold. Whenever a label in this wizard is not bold, that means this "argument" of the function is not required. However, if you do not enter anything in this box, Excel will apply the default. If you read the instructions at the bottom of this box, you will see that the default for this box is "true" which will find the "closest match", whereas "false" will find an "exact match". Since we want an exact match, type false in this box. This is what it should look like if you have entered all the info correctly:

Click OK and you will see that cell D2 now shows #N/A, which simply means that there is no value yet in C2, so the information is "not available". Look in your formula bar and you will see the formula is =VLOOKUP(C2,Customers,2,FALSE). As you get more used to using functions, you won't have to use the wizard as much if you take the time to look at the formulas and start to understand how they work. Now click into cell E2 and add a VLOOKUP formula which will find the Address in our table. The formula will be exactly the same, except the "Col_index_num" will be 3 instead of 2 because we want to return the address, which is in the third column of our table. Once you have added this, you should see another #N/A in cell E2. The formula will be =VLOOKUP(C2,Customers,3,FALSE). NOTE: All other information in the second VLOOKUP formula will be exactly the same as the first one. We are still looking for the value that will be placed in C2. We are still looking in the table named Customers. And we still want false for an exact match. The ONLY thing that is different is we are now going to pull the information from Column 3 instead of 2. Move to cell C2 and type in one of the Account numbers you have in your Accounts sheet and you will see Excel fills in the Customer Name and Address for that account number However, if you type a number that does not exist

on your Accounts sheet, Excel will leave the #N/A because the information for that number is "not available To see a VLOOKUP formula in action, go to this page at my website and view this interactive formula: http://www.personal-computer-tutor.com/vlookup.htm Now that we've gotten more comfortable with VLOOKUP, let's look at nesting formulas, one inside another. We can use the VLOOKUP formula we just made as a starter. Let's say we don't want to see that nasty old #N/A every time one of our VLOOKUP formulas refers to an empty cell or value that is not in our lookup table. What we need to do is tell Excel to show us the result of the VLOOKUP only IF it does not return a #NA result and, otherwise, just leave the cell empty. So we need to use three different functions in one formula: VLOOKUP, IF, and ISNA. Remember how we made an IF statement. =IF(<criteria>, <value if true>,<value if false>). If you don’t remember, read these two TechTrax articles I wrote: Intro to IF Statements: http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=225 Nesting IF Statements: http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=242 So, our criteria is IF the VLOOKUP returns #N/A, give me an empty cell, but if it doesn't, give me the result of the VLOOKUP. Let's try it. First we need to think about each of the three formulas and what they must include. We already have our VLOOKUP formula and we already know what an IF function must include, so the only one we need to learn is the ISNA function. All the ISNA function does is return a value of true or false. True if the cell has a #N/A error and false if it doesn't. So, since an IF statement wants to know if something is true or false, these two functions work very well together. Click into cell D2 in your Invoice sheet where your first VLOOKUP formula is. The thing you need to understand is that when you nest formulas within formulas, Excel performs the operation dictated by the deepest nested formula first, then works its way outward. So, enter the following formula into cell D2, then enter an account number in cell C2 that does not exist on your Accounts sheet and you will see that the #N/A error does not show. =IF(ISNA(VLOOKUP(C2,Customers,2,FALSE)),"",(VLOOKUP(C2,Custom ers,2,FALSE))) NOTE: Be sure to include all the proper commas and parentheses. Remember that all opening parentheses must have closing parentheses or Excel will give you an error message. Remember that Excel performs the deepest nested function first, so looking at the formula above, you will see:

•

The first thing Excel does is perform the first VLOOKUP (since that's the one that is nested deepest)

•

Then it performs the ISNA function on the result of the VLOOKUP to see if the VLOOKUP gave a #N/A error or not. The ISNA function returns a value of true if it sees the #N/A error and a value of false if it doesn't Then Excel performs the IF function on the result of the ISNA function. If it sees a "true", it returns nothing (which is what the "" tells it). If it is "false", it returns the result of the VLOOKUP function, which is what the last VLOOKUP function is telling it to do if the value is false

•

~~Ray Blake, GR Business Process Solutions Using VLOOKUP, HLOOKUP, INDEX, and MATCH in Excel to interrogate data tables

Lookup tables are fantastically useful things in Excel. I remember when someone showed me for the first time how to build a data table and perform some simple lookups on it. For the first time, I began to realise just how powerful Excel could be in the right hands. In this article, I'll talk about what a data table is, why you might find it useful to have one, and why and how you might want to interrogate it. We'll end with a trick or two involving some nested formulae, but by the time we get there, it will all make sense. First of all, then, what's a data table? Well, there's one shown below:

You'll notice that some related data is set out in columns, each with a heading in bold at the top. So many other functions in Excel can use those headings intelligently, that I have always made it a habit to put them in. Data tables like this have so many uses it's difficult to know where to start: phone number lists, CD collections, customer lists, the uses are endless. But sooner or later, you're going to want to extract data from such a list, perhaps for a mail merge or to fill in an invoice automatically, say. Probably the best way of learning about the LOOKUP functions is to ask some questions and use formulae to answer them. For instance, look again at the data

table above. If I want to know Barbara's age, I can use a command called VLOOKUP. It's called VLOOKUP because it looks up the data in a table, based on finding the key in a Vertical list. The formula I'd use here is: =VLOOKUP("Barbara",A2:C6,2,FALSE) Of course, this will return the number 23, which is Barbara's age. Let's look briefly at the format of the function. The first argument is the piece of data I want to look up (what I call the 'key') in the first column. (This must always be in the first column, but later on I'll show you how to find values based on a key in other columns instead.) The second argument is the range which contains the table, in this case A2:C6. I'd normally have named this range, but you don't have to. The third argument is the column number I want to return the value from. Looking at the table again, the first column contains names, the second ages and the third locations. Clearly, if I want to find Barbara's location, I'd put a 3 in this argument, but since I want to know her age, I've used 2. The fourth argument, the FALSE, is supposed to be an optional argument, but my advice is ALWAYS to use it. What it means is, "Don't rely on the list of items in the first column of the table being in alphanumeric order - check every one of them until you get an exact match." Leaving it out is like saying, "The first column of the lookup table is definitely in alphanumeric order - if you get past the search phrase in the list and it's not there, don't keep looking, just use the nearest match". This would speed up your sheet if there were a lot of huge data tables in it, but here it's not even worth thinking about. It's good practice always to include "FALSE" just in case it trips you up one day. Well, of course there's an HLOOKUP to match the VLOOKUP, too. You'd use this when your table is oriented left to right, rather than top to bottom. Here is an example of what I mean:

I can use the HLOOKUP function to find what date Debbie's birthday falls in like this: =HLOOKUP("Debbie",F2:J4,3,FALSE) This formula returns April. The arguments work the same way as for VLOOKUP, except of course that the third argument refers to the row number rather than the

column number. On the whole, it's much better to organise your data tables vertically, as in the first example, because a horizontal data table cannot be sorted or filtered by Excel as easily as a vertical one, but there are times when it has to be horizontal for some reason. The MATCH formula appears at first to do something quite unremarkable. Let's have another look at our vertical data table:

MATCH allows me to find the position of an item within a range. For instance, if I want to know how far down in the list of names Charlie is, I can use this formula: =MATCH("Charlie",A2:A6,0) The return from a MATCH function is always a number, in this case the number 3 because Charlie is the third entry in the range A2:A6. The zero at the end there is a bit like the 'FALSE' in VLOOKUP and HLOOKUP - optional but risky to omit. When set at zero, it says: "Make it an exact match". Ninety-nine times in a hundred, that's exactly what I want. INDEX is the opposite of MATCH in a way. It tells you what the nth value in a range is. For instance, who is in position 5 in the list? Easy: =INDEX(A2:A6,5) This returns the name 'Elvis' because he is the fifth item in the range A2:A6. Like INDEX, the MATCH function doesn't seem to do anything out of the ordinary so far. But the real power of these functions only becomes apparent when you combine them. Look at the vertical data table again and consider how you'd find out who lived in Belfast. The two LOOKUP formulas are no use, because the key value is not in the first column. Remember, VLOOKUP can only read values to the right of the key and HLOOKUP can only read values below the key. But, look at it another way. I can break the question down into two smaller ones, like this:

1. How far down the 'locations' list does 'Belfast' appear? 2. Whose name is in the 'names' list exactly as far down? Put in those terms, it is pretty clear. The first question can be answered, of course, by using a MATCH function: = MATCH("Belfast",C2:C6,0) This will tell us that Belfast is number 4 in the list, so we can put the number 4 into an INDEX formula: =INDEX(A2:A6,4) Of course, this formula will return the name 'Debbie', which answers the original question. But in the same way that original question is made up of two sub questions, so we can turn our two formulas into a single one, like this: =INDEX(A2:A6,MATCH("Belfast",C2:C6,0)) Again, this gives us the answer 'Debbie'. Of course, we've looked so far at simple tables, and it's been far quicker just to look at our table and answer the questions than to sit down and write formulae! However, there will be times when the data tables are huge, or when you want Excel to work things out for itself and get on with things. At times like those, you'll find that the LOOKUP functions of Excel are an invaluable part of your toolkit.

Sign up to vote on this title

UsefulNot useful- V LOOKUP
- Vlookup Troubleshooter
- Unit_16_lookup and Reference Function
- New Microsoft Office Word Document
- Excel function VLOOKUP
- Vlookup Tutorial
- Excel VLookup Function and VLookup Example
- BADM 2301 Spring 2014 Lab 5
- How to use VLOOKUP in Excel.docx
- Vlookup
- AF101984660 en-us Xl Qrc Vlookup Refresher
- EMT146-154
- Interview Material
- Advanced Excel Formulas
- vlookup
- How to Use Vlookup
- Excel Training Syllabus
- Handouts-Excel.pdf
- D1_CoolExcelTipsAndTricks
- Why Index Match is Better Than Vlookup
- Untitled
- Database Management...
- MS excel
- Excel Notes v lookup
- Excel Reporting Strategies - Chelsea Bloomfield Eckley
- E2010 EXPV1 CAP Instructions
- Certified Excel Expert_Finatics
- Excel - Vlookup
- -Excel Short Cuts
- Excel Project EXP E Capstone 1 - European Excursions 2.5
- Excel Lookup Functions Explained

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue reading from where you left off, or restart the preview.

scribd