34
THE ULTIMATE GUIDE TO EXCEL VLOOKUP FUNCTION This guide contains an Overview of the Excel VLOOKUP Function and 10 Examples that will make you a VLOOKUP Ninja! Created by: Sumit Bansal (Excel MVP, TrumpExcel.com)

FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

Embed Size (px)

Citation preview

Page 1: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

THE ULTIMATE GUIDETO EXCEL VLOOKUPFUNCTION

This guide contains an Overview of the Excel VLOOKUPFunction and 10 Examples that will make you a VLOOKUPNinja!

Created by: Sumit Bansal (Excel MVP, TrumpExcel.com)

Page 2: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

1.

2.

3.

4.

5.

6.

7.

Excel VLOOKUP FunctionAn Overview

VLOOKUP Example 1Finding Brad's Math Score

VLOOKUP Example 2Two-Way Lookup

VLOOKUP Example 3Using Drop Down Lists as Lookup Values

VLOOKUP Example 4Three-way Lookup

VLOOKUP Example 5Getting the Last Value from a List using the Excel VLOOKUPFunction

VLOOKUP Example 6Partial Lookup using Wildcard Characters and VLOOKUPfunction

Table of Contents

Page 3: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

8.

9.

10.

11.

12.

VLOOKUP Example 7VLOOKUP Returning an Error Despite a Match in Lookup Value

VLOOKUP Example 8Case Sensitive Lookup using the VLOOKUP Function

VLOOKUP Example 9Using VLOOKUP with Multiple Criteria

VLOOKUP Example 10Handling Errors while Using the Excel VLOOKUP Function

Can't Miss Excel Resources

Page 4: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

Excel VLOOKUP FunctionExcel VLOOKUP function is THE benchmark. You know something inExcel if you know how to use the VLOOKUP function. If you don't, youbetter not list Excel as one of your strong areas in your resume.

I have been a part of the panel interviews where as soon as thecandidate mentioned Excel as his area of expertise, the first thingasked was - you got it - the VLOOKUP function.

Excel VLOOKUP FunctionAn Overview

Page 5: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

Now that we know how important this Excel function is, it makessense to ace it completely to be able to proudly say - "I know a thing ortwo in Excel".

In this brief guide, I'll cover everything there is to know about theVLOOKUP function, and then show the power if it by using examples.

So buckle up. It's time for the takeoff.

When to use the Excel VLOOKUP FunctionExcel VLOOKUP function is best suited for situations when you arelooking for a matching data point in a column, and when the matchingdata point is found, you go to the right in that row and fetch a valuefrom a cell which is a specified number of columns to the right.

Let's take a simple example here to understand when to use the ExcelVLOOKUP function.

Remember when the exam score list was out and pasted on the noticeboard and everyone used to go crazy finding their names and theirscore (at least that's what used to happen when I was in school).

Here is how it worked:

You go up to the notice board and start looking for your name orenrolment number (running your finger from top to bottom in thelist).As soon as you spot your name, you move your eyes to the right ofthe name/enrolment number to see your scores.

And that is exactly what VLOOKUP function does for you (feel free touse this example in your next interview).

VLOOKUP function looks for a specified value in a column (in the aboveexample, it was your name) and when it finds the specified match, it

Page 6: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

returns a value in the same row (the marks you obtained).

Syntax

=VLOOKUP(lookup_value, table_array, col_index_num,[range_lookup])

Input Arguments

lookup_value – lookup_value – this is the look-up value you are trying to find in theleft-most column of a table. It could be a value, a cell reference, or atext string. In the score sheet example, this would be your name.table_array – table_array – this is the table in which you are looking for the value.This could be a reference to a range of cells or a named range. In thescore sheet example, this would be the entire table that containsscore for everyone for every subjectcol_index – col_index – this is the column number from which you want tofetch the matching value. In the score sheet example, if you wantthe scores for Math (which is the first column in a table thatcontains the scores), you'd look in column 1. If you want the scoresfor Physics, you'd look in column 2.[range_lookup][range_lookup] – – here you specify whether you want an exactmatch or an approximate match. If omitted, it defaults to TRUE –approximate match (see additional notes below).

Additional Notes (Boring, but important to know)

The match could be exact (FALSE or 0 in range_lookup) orapproximate (TRUE or 1).In approximate lookup, make sure that the list is sorted inascending order (top to bottom), or else the result could beinaccurate.When range_lookup is TRUE (approximate lookup) and data issorted in ascending order:

If the VLOOKUP function can not find the value, it returns the

Page 7: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

largest value, which is less than the lookup_value.It returns a #N/A error if the lookup_value is smaller than thesmallest value.If lookup_value is text, wildcard characters can be used (refer tothe example below).

Now, hoping that you have a basic understanding of what VLOOKUPfunction can do, let's peel this onion and see some practical examplesof the VLOOKUP function.

Page 8: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

Finding Brad's Math ScoreIn the example below, I have a list wth student names in the left-mostcolumn and marks in different subjects in column B to E.

Now let's get to work and use the VLOOKUP function for what it doesbest. From the above data, I need to know how much Brad scored inMath.

Here is the VLOOKUP formula that will return Brad's Math score:

=VLOOKUP("Brad",$A$3:$E$10,2,0)

The above formula has four arguments:

"Brad": - this is the lookup value.$A$3:$E$10 - this is the range of cells in which we are looking.Remember that Excel looks for the lookup value in the left most

VLOOKUP Example 1Finding Brad's Math Score

Page 9: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

column. In this example, it would look for the name Brad in A3:A10(which is the left-most column of the specified array).2 - Once the function spots Brad's name, it will go to the secondcolumn of the array, and return the value in the same row as that ofBrad. The value 2 here indicated that we are looking for the scorefrom the second column of the specified array.0 - this tells the VLOOKUP function to only look for exact matches.

Here is how the VLOOKUP function works in the above example.

First, it looks for the value Brad in the left most column. It goes fromtop to bottom and finds the value in cell A6.

As soon as it finds the value, it goes to the right in the second columnand fetches the value in it.

You can use the same formula construct to get anyone's marks in anyof the subjects.

Page 10: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

For example, to find Maria's marks in Chemistry, use the followingformula:

=VLOOKUP("Maria",$A$3:$E$10,4,0)

In the above example, the lookup value (student's name) is entered indouble quotes. You can also use a cell reference that contains thelookup value.

The benefit of using a cell reference is that it makes the formuladynamic.

For example, if you have a cell with a student's name, and you arefetching the score for Math, the result would automatically updatewhen you change the student's name.

For example, in the example below, if I change the name from Brad toJill, the result in G4 would automatically update and return 75 (which isJill's score in Math).

Page 11: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

Click here to see a live demo of how this works.

If you enter a lookup value that is not found in the left-most column, itreturns a #N/A error.

Page 12: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

Two-Way Lookup Using the VLOOKUPFunctionIn Example 1, we hard-coded the column value. Hence, the formulawould always return the score for Math as we have used 2 as thecolumn number.

But what if you want to make both the VLOOKUP value and thecolumn number dynamic.

For example, in the example below, a two-way lookup means that youcan change the name of the student as well as the name of the subjectand it will fetch the correct score from the table

Click here to see the live demo.

VLOOKUP Example 2Two-Way Lookup

Page 13: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

To make this two-way lookup formula, you need to make the columndynamic as well. So when a user changes the subject, the formulaautomatically picks the correct column (2 in the case of Math, 3 in thecase of Physics, as so on..).

To do this, you need to use the MATCH function as the columnargument. Here is the formula that will do this:

=VLOOKUP(G4,$A$3:$E$10,MATCH(H3,$A$2:$E$2,0),0)

The above formula uses MATCH(H3,$A$2:$E$2,0) as the columnnumber.

MATCH function takes the subject name as the lookup value (in H3)and returns its position in A2:E2. Hence, if you use Math, it wouldreturn 2 as Math is found in B2 (which is the second cell in the specifiedarray range).

Want to learn more about MATCH Function - click here for a tutorialwith examples and video.

Page 14: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

Using Drop Down Lists as Lookup ValuesIn the above examples, we had to manually enter the data. That couldbe time-consuming and error-prone, especially if you have a huge listof lookup values.

A good idea in such cases is to create a drop down list of the lookupvalues (in this case, it could be student names and subjects) and thensimply choose from the list. Based on the selection, the formula wouldautomatically update the result.

Something as shown below:

This makes a good dashboard component as you can have a huge dataset with hundreds of students at the back end, but the end user (let'ssay a teacher) can quickly get the marks of a student in a subject bysimply making the selections from the drop down.

VLOOKUP Example 3Using Drop Down Lists as Lookup Values

Page 15: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

How to make this:

The formula used in this case is the same used in Example 2.

=VLOOKUP(G4,$A$3:$E$10,MATCH(H3,$A$2:$E$2,0),0) The lookup values have been converted into drop-down lists.

Here are the steps to create the drop down list:

Select the cell in which you want the drop-down list. In thisexample, in G4, we want the student names.Go to Data --> Data Tools --> Data Validation.In the Data Validation Dialogue box, within the settings tab, selectList from the Allow drop-down.In the source, select $A$3:$A$10Click OK.

Now you'll have the drop-down list in cell G4. Similarly, you can createone in H3 for the subjects.

Page 16: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

Three-way Lookup using the VLOOKUPFunctionWhat is a three-way lookup?

In Example 2, we've used one table with scores for students indifferent subjects. This is an example of a two-way lookup as we usetwo variables to fetch the score (student's name and the subject'sname).

Now, suppose in a year, a student has three different levels of exams,Unit Test, Midterm, and Final Examination (that's what I had when Iwas a student).

A three-way lookup would be the ability to get a student's marks for aspecified subject from the specified level of exam.

Something as shown below:

VLOOKUP Example 4Three-way Lookup

Page 17: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

In the above example, the VLOOKUP function can lookup in threedifferent tables (Unit Test, Midterm and Final Exam) and returns thescore for the specified student in the specified subject.

Here is the formula used in cell H4:

=VLOOKUP(G4,CHOOSE(IF(H2="Unit Test",1,IF(H2="Midterm",2,3)),$A$3:$E$7,$A$11:$E$15,$A$19:$E$23),MATCH(H3,$A$2:$E$2,0),0)

This formula uses the CHOOSE function to make sure the correct tableis referred to.

Let's analyze the CHOOSE part of the formula:

CHOOSE(IF(H2="Unit Test",1,IF(H2="Midterm",2,3)),$A$3:$E$7,$A$11:$E$15,$A$19:$E$23)

The first argument of the formula is IF(H2="UnitTest",1,IF(H2="Midterm",2,3)), which checks the cell H2 and see what

Page 18: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

level of exam is being referred to. If it's Unit Test, it returns $A$3:$E$7,which has the scores for Unit Test. If it's Midterm, it returns$A$11:$E$15, else it returns $A$19:$E$23.

Doing this makes the VLOOKUP table array dynamic and hence makesit a three-way lookup.

Getting the Last Value from a List using theExcel VLOOKUP FunctionYou can use Excel VLOOKUP function to get the last numerical valuefrom a list.

The largest positive number that you can use in Excel is9.99999999999999E+307. This also means that the largest lookupnumber in the VLOOKUP number is also the same.

I don’t think you would ever need any calculation involving such alarge number. And that is exactly what we can use get the last numberin a list.

Suppose you have a dataset (in A1:A14) as shown below and you wantto get the last number in the list.

VLOOKUP Example 5Getting the Last Value from a List using the Excel VLOOKUPFunction

Page 19: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

Here is the formula you can use:

=VLOOKUP(9.99999999999999E+307,$A$1:$A$14,TRUE)

Note that the formula above uses an approximate match VLOOKUP(notice TRUE at the end of the formula, instead of FALSE or 0).

Also, note that the list doesn't need to be sorted for this formula towork.

Here is how the approximate VLOOKUP function works. It scans theleft most column from top to bottom.

If it finds an exact match, it returns that value.If it finds a value that is higher than the lookup value, it returns thevalue in the cell above it.If the lookup value is greater than all the values in the list, it returnsthe last value.

In the above example, the third scenario is at work.

Since 9.99999999999999E+307 is the largest number that can be usedin Excel, when this is used as the lookup value, it returns the lastnumber from the list.

In the same way, you can also use it to return the last text item fromthe list. Here is the formula that can do that:

Page 20: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

=VLOOKUP("zzz",$A$1:$A$8,1,TRUE)

The same logic follows. Excel looks through all the names, and sincezzz is consider bigger than any name/text starting with alphabetsbefore zzz, it would return the last item from the list.

Page 21: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

Partial Lookup using Wildcard Charactersand VLOOKUP functionWildcard characters are awesome. It's that magic potion that givesyour formulas super powers.

Partial look-up is needed when you have to look for a value in a listand there isn’t an exact match.

For example, suppose you have a data set as shown below, and youwant to look for the company ABC in a list, but the list has ABC Ltdinstead of ABC.

You can not use ABC as the lookup value as there is no exact match incolumn A. Approximate match also leads to erroneous results and itrequires the list to be sorted in an ascending order.

However, you can use a wildcard character within the VLOOKUPfunction to get the match.

VLOOKUP Example 6Partial Lookup using Wildcard Characters and VLOOKUPfunction

Page 22: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

Enter the following formula in cell D2 and drag it to the other cells:

=VLOOKUP("*"&C2&"*",$A$2:$A$8,1,FALSE)

How does this formula work?

In the above formula, instead of using the lookup value as is, it isflanked on both sides with the wildcard character asterisk (*) –“*”&C2&”*”

An asterisk is a wildcard character in Excel and can represent anynumber of characters.

Using the asterisk on both sides of the lookup value tells Excel that itneeds to look for any text that contains the word in C2. It could haveany number of characters before or after the text in C2.

For example, cell C2 has ABC, so the VLOOKUP function looks throughthe names in A2:A8 and searches for ABC. It finds a match in cell A2, asit contains ABC in ABC Ltd. It doesn't matter if there are any charactersto the left or right of ABC. Until there is ABC in a text string, it will beconsidered a match.

Note: VLOOKUP function always returns the first matching value andstops looking further. So if you have ABC Ltd., and ABC Corporation in alist, it will return the first one and ignore the rest.

Page 23: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

VLOOKUP Returning an Error Despite aMatch in Lookup ValueIt can drive you crazy when you see that there is a matching lookupvalue and the VLOOKUP function is returning an error.

For example, in the below case, there is a match (Matt), but theVLOOKUP function still returns an error.

Now while we can see there is a match, what we can not see with anaked eye is that there could be leading or trailing spaces. If you havethese additional spaces before, after, or in between the lookup values,it ISN'T an exact match.

This is often the case when you import data from a database or get itfrom someone else. These leading/trailing spaces have a tendency to

VLOOKUP Example 7VLOOKUP Returning an Error Despite a Match in LookupValue

Page 24: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

sneak in.

The solution here is the TRIM function. It removes any leading ortrailing spaces or extra spaces between words.

Here is the formula that'll give you the right result.

=VLOOKUP("Matt",TRIM($A$2:$A$9),1,0)

Since this is an array formula, use Control + Shift + Enter instead of justEnter.

Another way could be to first treat your lookup array with the TRIMfunction to make sure all the additional spaces are gone, and then usethe VLOOKUP function as usual.

Page 25: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

Case Sensitive Lookup using the VLOOKUPFunctionBy default, the lookup value in the VLOOKUP function is not casesensitive. For example, if your lookup value is MATT, matt, or Matt, it'sall the same for the VLOOKUP function. It'll return the first matchingvalue irrespective of the case.

But if you want to do a case-sensitive lookup, you need to use theEXACT function along with the VLOOKUP function.

Here is an example:

As you can see, there are three cells with the same name (in A2, A4,and A5) but with a different alphabet case. On the right, we have thethree names (Matt, MATT, and matt) along with their scores in Math.

Now the VLOOKUP function is not equipped to handle case-sensitive

VLOOKUP Example 8Case Sensitive Lookup using the VLOOKUP Function

Page 26: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

lookup values. In this above example, it would always return 38, whichis the score for Matt in A2.

To make it case sensitive, we need to use a helper column (as shownbelow):

To get the values in the helper column, use the =ROW() function. It willsimply get the row number in the cell.

Once you have the helper column, here is the formula that will givethe case-sensitive lookup result.

=VLOOKUP(MAX(EXACT(E2,$A$2:$A$9)*(ROW($A$2:$A$9))),$B$2:$C$9,2,0)

Now let's break down and understand what this does:

EXACT(E2,$A$2:$A$9) - This part would compare the lookup value inE2 with all the values in A2:A9. It returns an array of TRUEs/FALSEswhere TRUE is returned where there is an exact match. In this case,it would return the following array:TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE.EXACT(E2,$A$2:$A$9)*(ROW($A$2:$A$9) - This part multiplies thearray of TRUEs/FALSEs with the row number. Wherever there is aTRUE, it gives the row number, else it gives 0. In this case, it wouldreturn 2;0;0;0;0;0;0;0.MAX(EXACT(E2,$A$2:$A$9)*(ROW($A$2:$A$9))) - This part returnsthe maximum value from the array of numbers. In this case, it

Page 27: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

would return 2 (which is the row number where there is an exactmatch).Now we simply use this number as the lookup value and use thelookup array as B2:C9

Note: Since this is an array formula, use Control + Shift + Enter insteadof just enter.

Page 28: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

Using VLOOKUP with Multiple CriteriaExcel VLOOKUP function, in its basic form, can look for one lookupvalue and return the corresponding value from the specified row. Butoften there is a need to use VLOOKUP with multiple criteria.

Suppose you have a data with students name, exam type, and theMath score (as shown below):

Using the VLOOKUP function to get the Math score for each studentfor respective exam levels could be a challenge.

VLOOKUP Example 9Using VLOOKUP with Multiple Criteria

Page 29: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

For example, if you try using VLOOKUP with Matt as the lookup value,it'll always return 91, which is the score for the first occurrence of Mattin the list. To get the score for Matt for each exam type (Unit Test, MidTerm and Final), you need to create a unique lookup value.

This can be done using the helper column. The first step is to insert ahelper column to the left of the scores.

Now, to create a unique qualifier for each instance of the name, usethe following formula in C2: =A2&"|"&B2

Copy this formula to all the cells in the helper column. This will createunique lookup values for each instance of a name (as shown below):

Page 30: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

Now, while there were repetitions of the names, there is no repetitionwhen the name is combined with the level of examination.

This makes it easy as now you can use the helper column values as thelookup values.

Here is the formula that'll give you the result in G3:I8.

=VLOOKUP($F3&"|"&G$2,$C$2:$D$19,2,0)

Here we have combined the student name and the level ofexamination to get the lookup value, and we use this lookup value andchecks it in the helper column to get the matching record.

Page 31: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

Note: In the above example, we have used | as the separator whilejoining text in the helper column. In some exceptionally rare (butpossible) conditions, you may have two criteria that are different butends up giving the same result when combined. Here is an example:

Note that while A2 and A3 are different and B2 and B3 are different,the combinations end up being the same. But if you use a separator,then even the combination would be different (D2 and D3).

Here is a detailed tutorial on how to use VLOOKUP with multiplecriteria without using helper columns.

Page 32: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

Handling Errors while Using the ExcelVLOOKUP FunctionExcel VLOOKUP function returns an error when it can not find thespecified lookup value. You may not want the ugly error valuedisturbing the aesthetics of your data in case VLOOKUP can't find avalue.

You can easily remove the error values with any meaning full text suchas "Not Available" or "Not Found".

For example, in the example below, when you try to find the score ofBrad in the list, it returns an error as Brad's name is not there in thelist.

To remove this error and replace it with something meaningful, wrapyour VLOOKUP function within the IFERROR function.

VLOOKUP Example 10Handling Errors while Using the Excel VLOOKUP Function

Page 33: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

Here is the formula:

=IFERROR(VLOOKUP(D2,$A$2:$B$7,2,0),"Not Found")

The IFERROR function checks if the value returned by the firstargument (which is the VLOOKUP function in this case) is an error ornot. If it's not an error, it returns the value by the VLOOKUP function,else it returns Not Found.

IFERROR function is available from Excel 2007 onwards. If you areusing versions prior to that, use the following function:

=IF(ISERROR(VLOOKUP(D2,$A$2:$B$7,2,0)),"Not Found",VLOOKUP(D2,$A$2:$B$7,2,0))

Note: I've tried my best to proof read this guide, but in case you find any errors or spelling

mistakes, please let me know at [email protected]

Warning: This is a free guide and you're allowed to share it with anyone who

needs it. You are NOT allowed to sell it or use it for any commercial purposes.

Page 34: FUNCTION TO EXCEL VLOOKUP THE ULTIMATE … · TO EXCEL VLOOKUP FUNCTION ... Want to learn more about MATCH Function - click here for a tutorial with examples and video. Using Drop

Here are some Excel Resources that will skyrocket your Excel learningand save a lot of time.

Excel Functions (Examples + Videos)FREE Excel TemplatesExcel Keyboard ShortcutsExcel Charting TipsExcel Dashboards Nuts & BoltsOnline Excel Dashboard Course

Can't Miss ExcelResources