Excel VLOOKUP function is probably one of the most known function out there and people know the name of it certainly but not many know the power of it and why it’s so famous.
Well today let’s dig in and find out know and how of this function.
VLOOKUP stands for “Vertical Lookup” and what that means is we are looking for results in the columns and there is also a sister function to VLOOKUP called HLOOKUP where H stands for horizontal and that is for getting values stored in the rows. We are going to focus on VLOOKUP and trust us once you understand how VLOOKUP works then the HLOOKUP will be much easier to understand.
In more technical terms VLOOKUP looks up using a unique identifier and brings you result associated with the lookup value.
FREE Excel Assessment Test PDF
Download Free Excel Assessment Test PDF EBook - 34 page work book with 10 Sample Questions from the real Excel Pre-Employment Exam. Answers and explanations included!!!
The VLOOKUP function is available across almost every spreadsheet platform including all versions of Excel, Excel Online, Google Sheets, Apple Numbers, OpenOffice and LibreOffice etc.
Excel VLOOKUP syntax
VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
There are four parts to VLOOKUP formula which make everything tick. Once you understand each of it, the concept will be easy to grasp. Let’s try and understand it in simple everyday terms, say finding a particular shirt in a wardrobe and suppose there are two sections to the wardrobe.
Okay so in those terms, the shirt we are looking for will be represented by lookup_value and “table_array” will represent the wardrobe and col_index_num will be representing one of the two sections of the wardrobe and finally the [range_lookup] is an optional parameter which will tell us whether we are looking exclusively for a particular shirt or we could be a little lose with the required demand.
So now you understand somewhat of what we are trying to do with this formula let’s try and understand each part of the syntax using the formula and real examples.
This part of the formula defines the value we are trying to search for and this could either be a value which could either be a value (number, text) and or cell reference (reference to a cell containing the lookup value).
Let’s have a look at some examples and how this works.
- In the first example we are going to look up using text “Green” and get the shirt number associated with the color Green, the formula for this in the case as shown in the figure below is VLOOKUP(“Green”,A3:B7,2,FALSE). As you can see for looking up text, we have to put the text between two quotation marks. Have a look at the example below to see the formula in action.
- In the second example we are going to look up a number using the VLOOKUP formula and it will be pretty much the same except we are going remove quotation marks from the equation, have a look at the figure below and see how we are doing that. The formula used in the figure below is VLOOKUP(10,A3:B7,2,FALSE)
- In the third example we are going to reference a cell and get the lookup value from the cell and get the results from our VLOOKUP function and in the below example I going to reference the cell D2 and get the results by looking up value from there and the benefit of doing this is you can lookup many values without having to change formula every time. So, the formula for looking up using the cell D2 would look like VLOOKUP(D2,A3:B7,2,FALSE). Have a look at the example below to understand it better.
This section defines usually two or more columns of data the VLOOKUP function looks for value. The VLOOKUP function always looks for identifier in the first column so from above see the identifier was first the color and on next example, the identifier is the “Shirt #” and in both the figures you can see the lookup column is the first one.
The Lookup values are case insensitive so you can enter values without worrying about whether its upper case or lower case.
Have a look at the figure above the formula used in it, is VLOOKUP(“Green”,A3:B7,2,FALSE) and you can see the colors are listed in column are A3:A7 and that is the starting column of the array and same with Fig 2 VLOOKUP(10,A3:B7,2,FALSE) you can see the lookup value “Shirt #” is again stored in column in section A3:A7 which again is in the start of the table_array.
This part of formula defines the column from which we want to get the results from as explained above the left-most column in a VLOOKUP array is always reserved for the identifier and so if we are looking for any value in the column right next to the identifier then the column index number would be 2 as the first column is our identifier and the next column is our results that we want to extract.
Have a look at the examples shown above to see that in all the instances above the column number is 2 and that is because we are extracting the second column value.
Have a look at the figure 4 to see a different example of the same. In the following example the formula used is VLOOKUP(E2,A3:C7,3,FALSE) and as you can see as a result we are getting the results from the column C.
The fourth and final piece of the puzzle of a VLOOKUP formula is either TRUE or FALSE and while optional as per Excel it should rarely be considered optional as the formula defaults to TRUE when left unfilled.
So, the difference between TRUE and FALSE is simple whenever we are looking for exact results, we should always use FALSE as we have been doing in all of our examples above and TRUE range lookup is useful for finding approximate results.
So how does approximate results work, essentially it matches the closes lowest value with lookup value and so for best results its always advised to use it on data sorted by ascending order.
Let’s have a look at couple of examples of approximate match to further drive our point home
- Example 1
The first example shows the approximate match of 250 and Excel finds the lowest close value to the lookup value which is 120 and note while 250 will be much closer to 300 but it finds the lowest closest value to 120 it is and gets us the result from the second column.
Have a look at the figure below to see the formula in action.
- Example 2
In this example we are looking up for the value 60 and you can notice it in the figure below, Excel finds us the results against the 50 value. Which again follows the same rule, that is finding the lowest closest value.
Now that we have figured out how this formula works and what elements make it tick, now let’s figure how you can use it and how can it benefit you in the long run.
You can do a lot with VLOOKUP and that includes looking up data in the same sheet, looking up data in the different worksheets, looking up data in different workbooks.
We have already seen VLOOKUP in action in the same sheet and so now let’s look at some other examples and explore more on what you can do.
Let’s have a look at different scenarios using real examples.
VLOOKUP in Excel from other sheets
It’s very rare sight to see VLOOKUP done on the same sheet, as its usually done to find correlating data across the sheets and in order to do that we have to reference the table_array argument using the sheet name followed by exclamation mark and occasionally surround the sheet name by single quotation marks depending on if the sheet name has space in its name.
Alternatively you can simply type the lookup_value and then switch the sheet and navigate to the data where it is and select the entire array area and it will populate the array range on the formula with the correct format and I recommend this method as opposed to typing as it will help you save a ton of time and problem solving with the format.
With that said let’s look at a couple of real examples.
- Example 1
In the first example below you can see we are referencing the table_array part of the formula from the “sheet5” and as you can see it follows the naming convention we explained above the “sheet5” is the sheet name followed by the exclamation mark followed by the range of the table_array.
- Example 2
Now in the second example I am going to show you how the single quotation marks play their part in the naming of the sheet.
As you can see below in, I used the same example I just changed the sheet name to “Sheet Name” and you can see how the sheet name is now wrapped around a single quotation mark and that is how Excel deals with the space in the names.
VLOOKUP in Excel from other Workbooks
This is another spectacular way you can use VLOOKUP to solve any of your problems. Suppose you want get information from a different workbook using a common identifier and so if you have the workbook open then all you need to do is have the workbook name be surrounded by square brackets.
So, suppose the sheet name is “Sheet Name” and workbook name is “tutorial” then your formula would look like something like this =VLOOKUP(C3,'[tutorial.xlsx]Sheet Name’!A3:B14,2,FALSE).
Now as you can see, we already utilized the spacing in this example and as a result the sheet and workbook name is surrounded by single quotation marks.
Now once you close your workbook with the lookup_array then your formula will now show the full path of the workbook have a look below in the example to see it in action.
One big tip I would always suggest going for is select the range by navigating to workbook and sheet, instead of typing it as it will automatically fill up the workbook, sheet and range name without you have to do any typing at all.
Using Named Ranges with VLOOKUP
Like a lot of things in Excel, you can refer to named ranges in the lookup_array segment to make your formulas easier to write and more dynamic than say a static range.
Using named range is pretty simple in the VLOOKUP for example we define a named range after selecting a range and creating a range name by simply typing it in there. Named Ranges can’t have spaces in its name and we will go in more detail about the same some other time
Have a look below in order to see us creating a named range then after that we will create a VLOOKUP formula using that.
As you can see below, we have used the named range we created above in the below formula in lookup_array segment successfully.
The formula used below is =VLOOKUP(E2,Wardrobe,3,FALSE) which does not refer directly to a range but will work just as the same.
Some things to note while using VLOOKUP.
- VLOOKUP function always looks at right and the identifier has to be the very first column in the table_array for it to work.
- VLOOKUP is case insensitive so BuS is same as bUS.
- Always use absolute values while defining ranges i.e. use ranges with dollar signs to fix the table_array range as that would not be a problem when dragging the formula. So, for example in place of A3:B7 use $A$3:$B$7 as that fixes the range.
- Also, in most cases you will be using “False” parameter so try to stick to that unless on places where you want approximate matches which are rare.
- About the errors
- #N/A error occurs when VLOOKUP can’t find a match.
- #VALUE! error occurs when the col_index_num is less than 1.
- In case the col_index_num is higher than the number supplied in the array then the #REF! error is reflected in the formula.
Exercise & More.
What would the correct formula for the looking up the value of shirt # corresponding to the color Yellow based on the following example data?
The correct Answer is A. Now let’s look at the other wrong options and see what’s wrong, the option B is wrong because the lookvalue_value argument is text and its not surrounded by double quotations marks and that would not work and throw and error. In the same vain the option C is wrong as well as again the lookup_value is not surrounded by double quotation marks and additionally since we are looking up for exact value the fourth argument is set to lookup approximate value and finally the last option has the wrong column number as col_index_num and so it will result in “Yellow” as a result and which is not the desired answer.
What would be the correct formula for looking up number 30 and give us the color corresponding to the number based on the references as per the following image.
The correct answer is option B. Lets look at the wrong answers and figure out what’s wrong. The option A is wrong is because we are looking up a number and lookup_value is surrounded by double quotations marks and option C would wrong because lookup_value again is number but in the first argument the value is surrounded by double quotation marks and which would be wrong and also the col_index_num argument is wrong as well as we are looking up results from second column. Finally, the answer is the column D is wrong because the fourth argument is set to TRUE and we are looking for exact results.
What would be the correct formula for referencing another cell and get a VLOOKUP results from the column that contains pant # based on the cell E2 and the array shown in the image below?
The correct answer is answer A. Now let’s review the wrong options and figure out why they are not right. The answer in option B is wrong because the lookup_value argument is wrong as the lookup cell is surrounded by double quotation marks and that shouldn’t be the case when referencing the cell. The option c is wrong because we are looking for results in column 3 and the argument is set to 2 and that is wrong and finally the answer D is wrong because of both the issues that we discussed in option B and C.
For finding best results in approximate match we have to sort the data by which order?
The correct answer is B.
VLOOKUP can only look for value on which side of identifier column
- Left but with some alteration to the formula
- Not Applicable
The correct answer is B.
Which is the correct VLOOKUP formula for dataset shown on the below image which resides on sheet “Data here” and we are referencing from the sheet Question 6 for finding the Shirt # based on the color “Cyan”.
- =VLOOKUP(“CYAN”,’Data Here’!A3:C7,2,FALSE)
- =VLOOKUP(Cyan,’Data Here’!A3:C7,2,FALSE)
- =VLOOKUP(“Cyan”,Data Here!A3:C7,2,FALSE)
- =VLOOKUP(CYAN,Data Here!A3:C7,2,FALSE)
The correct option is A and Let’s review the wrong answers to observe the mistake the option B is wrong because we are looking up a textual value and lookup_value argument is not surrounded by double quotation marks and that wouldn’t work. The option C is wrong because the sheet name has a space in it and the sheet name is not surrounded by single quotation marks. And finally, option D is wrong because the lookup_value is not surrounded by double quotations marks and sheet name is not surrounded by single quotation marks even though the sheet name has a space in it.