Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel 2010 Excel 2007 Excel for Mac 2011 Excel Starter 2010 More…Less
Tip: Try using the new XLOOKUP function, an improved version of VLOOKUP that works in any direction and returns exact matches by default, making it easier and more convenient to use than its predecessor.
Use VLOOKUP when you need to find things in a table or a range by row. For example, look up a price of an automotive part by the part number, or find an employee name based on their employee ID.
In its simplest form, the VLOOKUP function says:
=VLOOKUP(What you want to look up, where you want to look for it, the column number in the range containing the value to return, return an Approximate or Exact match – indicated as 1/TRUE, or 0/FALSE).
Tip: The secret to VLOOKUP is to organize your data so that the value you look up (Fruit) is to the left of the return value (Amount) you want to find.
Use the VLOOKUP function to look up a value in a table.
Syntax
VLOOKUP (lookup_value, table_array, col_index_num, [range_lookup])
For example:
-
=VLOOKUP(A2,A10:C20,2,TRUE)
-
=VLOOKUP(«Fontana»,B2:E7,2,FALSE)
-
=VLOOKUP(A2,’Client Details’!A:F,3,FALSE)
Argument name |
Description |
---|---|
lookup_value (required) |
The value you want to look up. The value you want to look up must be in the first column of the range of cells you specify in the table_array argument. For example, if table-array spans cells B2:D7, then your lookup_value must be in column B.
|
table_array (required) |
The range of cells in which the VLOOKUP will search for the lookup_value and the return value. You can use a named range or a table, and you can use names in the argument instead of cell references. The first column in the cell range must contain the lookup_value. The cell range also needs to include the return value you want to find. Learn how to select ranges in a worksheet. |
col_index_num (required) |
The column number (starting with 1 for the left-most column of table_array) that contains the return value. |
range_lookup (optional) |
A logical value that specifies whether you want VLOOKUP to find an approximate or an exact match:
|
How to get started
There are four pieces of information that you will need in order to build the VLOOKUP syntax:
-
The value you want to look up, also called the lookup value.
-
The range where the lookup value is located. Remember that the lookup value should always be in the first column in the range for VLOOKUP to work correctly. For example, if your lookup value is in cell C2 then your range should start with C.
-
The column number in the range that contains the return value. For example, if you specify B2:D11 as the range, you should count B as the first column, C as the second, and so on.
-
Optionally, you can specify TRUE if you want an approximate match or FALSE if you want an exact match of the return value. If you don’t specify anything, the default value will always be TRUE or approximate match.
Now put all of the above together as follows:
=VLOOKUP(lookup value, range containing the lookup value, the column number in the range containing the return value, Approximate match (TRUE) or Exact match (FALSE)).
Examples
Here are a few examples of VLOOKUP:
Example 1
Example 2
Example 3
Example 4
Example 5
You can use VLOOKUP to combine multiple tables into one, as long as one of the tables has fields in common with all the others. This can be especially useful if you need to share a workbook with people who have older versions of Excel that don’t support data features with multiple tables as data sources — by combining the sources into one table and changing the data feature’s data source to the new table, the data feature can be used in older Excel versions (provided the data feature itself is supported by the older version).
Here, columns A-F and H have values or formulas that only use values on the worksheet, and the rest of the columns use VLOOKUP and the values of column A (Client Code) and column B (Attorney) to get data from other tables. |
-
Copy the table that has the common fields onto a new worksheet, and give it a name.
-
Click Data > Data Tools > Relationships to open the Manage Relationships dialog box.
-
For each listed relationship, note the following:
-
The field that links the tables (listed in parentheses in the dialog box). This is the lookup_value for your VLOOKUP formula.
-
The Related Lookup Table name. This is the table_array in your VLOOKUP formula.
-
The field (column) in the Related Lookup Table that has the data you want in your new column. This information is not shown in the Manage Relationships dialog — you’ll have to look at the Related Lookup Table to see which field you want to retrieve. You want to note the column number (A=1) — this is the col_index_num in your formula.
-
-
To add a field to the new table, enter your VLOOKUP formula in the first empty column using the information you gathered in step 3.
In our example, column G uses Attorney (the lookup_value) to get the Bill Rate data from the fourth column (col_index_num = 4) from the Attorneys worksheet table, tblAttorneys (the table_array), with the formula =VLOOKUP([@Attorney],tbl_Attorneys,4,FALSE).
The formula could also use a cell reference and a range reference. In our example, it would be =VLOOKUP(A2,’Attorneys’!A:D,4,FALSE).
-
Continue adding fields until you have all the fields that you need. If you are trying to prepare a workbook containing data features that use multiple tables, change the data source of the data feature to the new table.
Problem |
What went wrong |
---|---|
Wrong value returned |
If range_lookup is TRUE or left out, the first column needs to be sorted alphabetically or numerically. If the first column isn’t sorted, the return value might be something you don’t expect. Either sort the first column, or use FALSE for an exact match. |
#N/A in cell |
For more information on resolving #N/A errors in VLOOKUP, see How to correct a #N/A error in the VLOOKUP function. |
#REF! in cell |
If col_index_num is greater than the number of columns in table-array, you’ll get the #REF! error value. For more information on resolving #REF! errors in VLOOKUP, see How to correct a #REF! error. |
#VALUE! in cell |
If the table_array is less than 1, you’ll get the #VALUE! error value. For more information on resolving #VALUE! errors in VLOOKUP, see How to correct a #VALUE! error in the VLOOKUP function. |
#NAME? in cell |
The #NAME? error value usually means that the formula is missing quotes. To look up a person’s name, make sure you use quotes around the name in the formula. For example, enter the name as «Fontana» in =VLOOKUP(«Fontana»,B2:E7,2,FALSE). For more information, see How to correct a #NAME! error. |
#SPILL! in cell |
This particular #SPILL! error usually means that your formula is relying on implicit intersection for the lookup value, and using an entire column as a reference. For example, =VLOOKUP(A:A,A:C,2,FALSE). You can resolve the issue by anchoring the lookup reference with the @ operator like this: =VLOOKUP(@A:A,A:C,2,FALSE). Alternatively, you can use the traditional VLOOKUP method and refer to a single cell instead of an entire column: =VLOOKUP(A2,A:C,2,FALSE). |
Do this |
Why |
---|---|
Use absolute references for range_lookup |
Using absolute references allows you to fill-down a formula so that it always looks at the same exact lookup range. Learn how to use absolute cell references. |
Don’t store number or date values as text. |
When searching number or date values, be sure the data in the first column of table_array isn’t stored as text values. Otherwise, VLOOKUP might return an incorrect or unexpected value. |
Sort the first column |
Sort the first column of the table_array before using VLOOKUP when range_lookup is TRUE. |
Use wildcard characters |
If range_lookup is FALSE and lookup_value is text, you can use the wildcard characters—the question mark (?) and asterisk (*)—in lookup_value. A question mark matches any single character. An asterisk matches any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) in front of the character. For example, =VLOOKUP(«Fontan?»,B2:E7,2,FALSE) will search for all instances of Fontana with a last letter that could vary. |
Make sure your data doesn’t contain erroneous characters. |
When searching text values in the first column, make sure the data in the first column doesn’t have leading spaces, trailing spaces, inconsistent use of straight ( ‘ or » ) and curly ( ‘ or “) quotation marks, or nonprinting characters. In these cases, VLOOKUP might return an unexpected value. To get accurate results, try using the CLEAN function or the TRIM function to remove trailing spaces after table values in a cell. |
Need more help?
You can always ask an expert in the Excel Tech Community or get support in the Answers community.
See Also
XLOOKUP function
Video: When and how to use VLOOKUP
Quick Reference Card: VLOOKUP refresher
How to correct a #N/A error in the VLOOKUP function
Look up values with VLOOKUP, INDEX, or MATCH
HLOOKUP function
Need more help?
VLOOKUP is an Excel function to get data from a table organized vertically. Lookup values must appear in the first column of the table passed into VLOOKUP. VLOOKUP supports approximate and exact matching, and wildcards (* ?) for partial matches.
Vertical data | Column Numbers | Only looks right | Matching Modes | Exact Match | Approximate Match | First Match | Wildcard Match | Two-way Lookup | Multiple Criteria | #N/A Errors | Videos
Introduction
VLOOKUP is probably the most famous function in Excel, for reasons both good and bad. On the good side, VLOOKUP is easy to use and does something very useful. For new users in particular, it is immensely satisfying to watch VLOOKUP scan a table, find a match, and return a correct result. Using VLOOKUP successfully is a rite of passage for new Excel users.
On the bad side, VLOOKUP is limited and has dangerous defaults. Unlike INDEX and MATCH (or XLOOKUP), VLOOKUP needs a complete table with lookup values in the first column. This makes it hard to use VLOOKUP with multiple criteria. In addition, VLOOKUP’s default matching behavior makes it easy to get incorrect results. Fear not. The key to using VLOOKUP successfully is mastering the basics. Read on for a complete overview.
Arguments
VLOOKUP takes four arguments: lookup_value, table_array, column_index_num, and range_lookup. Lookup_value is the value to look for, and table_array is the range of vertical data to look inside. The first column of table_array must contain the lookup values to search. The column_index_num argument is the column number of the value to retrieve, where the first column of table_array is column 1. Finally, range_lookup controls match behavior. If range_lookup is TRUE, VLOOKUP will perform an approximate match. If range_lookup is FALSE, VLOOKUP will perform an exact match. Important: range_lookup is optional and defaults to TRUE, so VLOOKUP will perform an approximate match by default. See below for more information on matching.
V is for vertical
The purpose of VLOOKUP is to look up information in a table like this:
With the Order number in column B as the lookup_value, VLOOKUP can get the Cust. ID, Amount, Name, and State for any order. For example, to get the name for order 1004, the formula is:
=VLOOKUP(1004,B5:F9,4,FALSE) // returns "Sue Martin"
To look up horizontal data, you can use HLOOKUP, INDEX and MATCH, or XLOOKUP.
VLOOKUP is based on column numbers
When you use VLOOKUP, imagine that every column in the table_array is numbered, starting from the left. To get a value from a given column, provide the number for column_index_num. For example, the column index to retrieve the first name below is 2:
By changing only column_index_num, you can look up columns 2, 3, and 4:
=VLOOKUP(H3,B4:E13,2,FALSE) // first name
=VLOOKUP(H3,B4:E13,3,FALSE) // last name
=VLOOKUP(H3,B4:E13,4,FALSE) // email address
Note: normally, we would use an absolute reference for H3 ($H$3) and B4:E13 ($B$4:$E$13) to prevent these from changing when the formula is copied. Above, the references are relative to make them easier to read.
VLOOKUP only looks right
VLOOKUP can only look to the right. In other words, you can only retrieve data to the right of the column that holds lookup values:
To look up values to the left, see INDEX and MATCH, or XLOOKUP.
Match modes
VLOOKUP has two modes of matching, exact and approximate, controlled by the fourth argument, range_lookup. The word «range» in this case refers to «range of values» – when range_lookup is TRUE, VLOOKUP will match a range of values rather than an exact value. A good example of this is using VLOOKUP to calculate grades. When range_lookup is FALSE, VLOOKUP performs an exact match, as in the example above.
Important: range_lookup is optional defaults to TRUE. This means approximate match mode is the default, which can be dangerous. Set range_lookup to FALSE to force exact matching:
=VLOOKUP(value,table,col_index) // approximate match (default)
=VLOOKUP(value,table,col_index,TRUE) // approximate match
=VLOOKUP(value,table,col_index,FALSE) // exact match
Tip: always supply a value for range_lookup as a reminder of expected behavior.
Note: You can also supply zero (0) for an exact match, and 1 for an approximate match.
Exact match example
In most cases, you’ll probably want to use VLOOKUP in exact match mode. This makes sense when you have a unique key to use as a lookup value, for example, the movie title in this data:
The formula in H6 to find Year, based on an exact match of the movie title, is:
=VLOOKUP(H4,B5:E9,2,FALSE) // FALSE = exact match
Approximate match example
In some cases, you will need an approximate match lookup instead of an exact match lookup. For example, below we want to find the correct commission percentage in the range G5:H10 based on the sales amount in column C. In this example, we need to use VLOOKUP in approximate match mode, because in most cases an exact match will never be found. The VLOOKUP formula in D5 is configured to perform an approximate match by setting the last argument to TRUE:
=VLOOKUP(C5,$G$5:$H$10,2,TRUE) // TRUE = approximate match
VLOOKUP will scan values in column G for the lookup value. If an exact match is found, VLOOKUP will use it. If not, VLOOKUP will «step back» and match the previous row.
Note: The table_array must be sorted in ascending order by lookup value to use an approximate match. If table_array is not sorted by the first column in ascending order, VLOOKUP may return incorrect or unexpected results.
First match only
In the case of duplicate matching values, VLOOKUP will find the first match. In the screen below, VLOOKUP is configured to find the price for the color «Green». There are three rows with the color Green, and VLOOKUP returns the price in the first row, $17. The formula in cell F5 is:
=VLOOKUP(E5,B5:C11,2,FALSE) // returns 17
Tip: To retrieve multiple matches with a lookup operation, see the FILTER function.
Wildcard match
The VLOOKUP function supports wildcards, which makes it possible to perform a partial match on a lookup value. For instance, you can use VLOOKUP to retrieve information from a table with a partial lookup_value and wildcard. To use wildcards with VLOOKUP, you must use exact match mode by providing FALSE for range_lookup. In the screen below, the formula in H7 retrieves the first name, «Michael», after typing «Aya» into cell H4. Notice the asterisk (*) wildcard is concatenated to the lookup value inside the VLOOKUP formula:
=VLOOKUP($H$4&"*",$B$5:$E$104,2,FALSE)
Read a more detailed explanation here.
Two-way lookup
Inside the VLOOKUP function, column_index_num is normally hard-coded as a static number. However, you can create a dynamic column index by using the MATCH function to locate the needed column. This technique allows you to create a dynamic two-way lookup, matching on both rows and columns. In the screen below, VLOOKUP is configured to perform a lookup based on Name and Month like this:
=VLOOKUP(H4,B5:E13,MATCH(H5,B4:E4,0),0)
For more details, see this example.
Note: In general, INDEX and MATCH is a more flexible way to perform two-way lookups.
Multiple criteria
The VLOOKUP function does not handle multiple criteria natively. However, you can use a helper column to join multiple fields together and use these fields like multiple criteria inside VLOOKUP. In the example below, Column B is a helper column that concatenates first and last names together with this formula:
=C5&D5 // helper column
VLOOKUP is configured to do the same thing to create a lookup value. The formula in H6 is:
=VLOOKUP(H4&H5,B5:E13,4,0)
For details, see this example. For a more advanced, flexible approach, see this example.
Note: INDEX and MATCH and XLOOKUP are better for lookups based on multiple criteria.
VLOOKUP and #N/A errors
If you use VLOOKUP you will inevitably run into the #N/A error. The #N/A error means «not found». For example, in the screen below, the lookup value «Toy Story 2» does not exist in the lookup table, and all three VLOOKUP formulas return #N/A:
The #N/A error is useful because tells you something is wrong. The reason for #N/A might be:
- The lookup value does not exist in the table
- The lookup value is misspelled or contains extra space
- Match mode is exact, but should be approximate
- The table range is not entered correctly
- You are copying VLOOKUP, and the table reference is not locked
To «trap» the NA error and return a different value, you can use the IFNA function like this:
The formula in H6 is:
=IFNA(VLOOKUP(H4,B5:E9,2,FALSE),"Not found")
The message can be customized as desired. To return nothing (i.e. to display a blank result) when VLOOKUP returns #N/A you can use an empty string («») like this:
=IFNA(VLOOKUP(H4,B5:E9,2,FALSE),"") // no message
You can also use the IFERROR function to trap VLOOKUP #N/A errors. However, be careful with IFERROR, because it will catch any error, not just the #N/A error. Read more: VLOOKUP without #N/A errors
More about VLOOKUP
- VLOOKUP with multiple criteria (basic)
- VLOOKUP with multiple criteria (advanced)
- How to use VLOOKUP to merge tables
- 23 tips for using VLOOKUP
- More VLOOKUP examples and videos
- XLOOKUP vs VLOOKUP
Other notes
- VLOOKUP performs an approximate match by default.
- VLOOKUP is not case-sensitive.
- Range_lookup controls the match mode. FALSE = exact, TRUE = approximate (default).
- If range_lookup is omitted or TRUE or 1:
- VLOOKUP will match the nearest value less than the lookup_value.
- VLOOKUP will still use an exact match if one exists.
- The column 1 of table_array must be sorted in ascending order.
- If range_lookup is FALSE or zero:
- VLOOKUP performs an exact match.
- Column 1 of table_array does not need to be sorted.
Coordinating a massive amount of data in Microsoft Excel is a time-consuming headache. That headache can be made even worse when you need to compare data across multiple spreadsheets. The last thing you want to do is manually transfer cells using copy and paste. Thankfully, you don’t have to. The VLOOKUP function can help you automate this task and save you tons of time.
I know, «VLOOKUP function» sounds like the geekiest, most complicated thing ever. But by the time you finish reading this article, you’ll wonder how you ever survived in Excel without it.
Microsoft Excel’s VLOOKUP function is easier to use than you think. What’s more, it is incredibly powerful, and is definitely something you want to have in your arsenal of analytical weapons.What does VLOOKUP do, exactly? Here’s the simple explanation: The VLOOKUP function searches for a specific value in your data, and once it identifies that value, it can find — and display — some other piece of information that’s associated with that value.
How does VLOOKUP work?
VLOOKUP stands for «vertical lookup.» In Excel, this means the act of looking up data vertically across a spreadsheet, using the spreadsheet’s columns — and a unique identifier within those columns — as the basis of your search. When you look up your data, it must be listed vertically wherever that data is located.
The formula always searches to the right.
When conducting a VLOOKUP in Excel, you’re essentially looking for new data in a different spreadsheet that is associated with old data in your current one. When VLOOKUP runs this search, it always looks for the new data to the right of your current data.
For instance, if one spreadsheet has a vertical list of names, and another spreadsheet has an unorganized list of those names and their email addresses, you can use VLOOKUP to retrieve those email addresses in the order you have them in your first spreadsheet. Those email addresses must be listed in the column to the right of the names in the second spreadsheet, or Excel won’t be able to find them. (Go figure … )
The formula needs a unique identifier to retrieve data.
The secret to how VLOOKUP works? Unique identifiers.
A unique identifier is a piece of information that both of your data sources share, and — as its name implies — it is unique (i.e. the identifier is only associated with one record in your database). Unique identifiers include product codes, stock-keeping units (SKUs), and customer contacts.
Alright, enough explanation: let’s see another example of the VLOOKUP in action!
VLOOKUP Example
In the video below, we’ll show an example in action, using the VLOOKUP function to match email addresses (from a second data source) to their corresponding data in a separate sheet.
Author’s note: There are many different versions of Excel, so what you see in the video above might not always match up exactly with what you’ll see in your version. That’s why we encourage you to follow along with the written instructions below.
- Identify a column of cells you’d like to fill with new data.
- Select ‘Function’ (Fx) > VLOOKUP and insert this formula into your highlighted cell.
- Enter the lookup value for which you want to retrieve new data.
- Enter the table array of the spreadsheet where your desired data is located.
- Enter the column number of the data you want Excel to return.
- Enter your range lookup to find an exact or approximate match of your lookup value.
- Click ‘Done’ (or ‘Enter’) and fill your new column.
For your reference, here’s what a VLOOKUP function looks like:
VLOOKUP(lookup_value , table_array , col_index_num , range_lookup)
In the steps below, we’ll assign the right value to each of these components, using customer names as our unique identifier to find the MRR of each customer.
1. Identify a column of cells you’d like to fill with new data.
Remember, you’re looking to retrieve data from another sheet and deposit it into this one. With that in mind, label a column next to the cells you want more information on with a proper title in the top cell, such as «MRR,» for monthly recurring revenue. This new column is where the data you’re fetching will go.
2. Select ‘Function’ (Fx) > VLOOKUP and insert this formula into your highlighted cell.
To the left of the text bar above your spreadsheet, you’ll see a small function icon that looks like a script: Fx. Click on the first empty cell beneath your column title and then click this function icon. A box titled Formula Builder or Insert Function will appear to the right of your screen (depending on which version of Excel you have).
Search for and select «VLOOKUP» from the list of options included in the Formula Builder. Then, select OK or Insert Function to start building your VLOOKUP. The cell you currently have highlighted in your spreadsheet should now look like this: «=VLOOKUP()«
You can also enter this formula into a call manually by entering the bold text above exactly into your desired cell.
With the =VLOOKUP text entered into your first cell, it’s time to fill the formula with four different criteria. These criteria will help Excel narrow down exactly where the data you want is located and what to look for.
3. Enter the lookup value for which you want to retrieve new data.
The first criteria is your lookup value — this is the value of your spreadsheet that has data associated with it, which you want Excel to find and return for you. To enter it, click on the cell that carries a value you’re trying to find a match for. In our example, shown above, it’s in cell A2. You’ll start migrating your new data into D2, since this cell represents the MRR of the customer name listed in A2.
Keep in mind your lookup value can be anything: text, numbers, website links, you name it. As long as the value you’re looking up matches the value in the referring spreadsheet — which we’ll talk about that in the next step — this function will return the data you want.
4. Enter the table array of the spreadsheet where your desired data is located.
Next to the «table array» field, enter the range of cells you’d like to search and the sheet where these cells are located, using the format shown in the screenshot above. The entry above means the data we’re looking for is in a spreadsheet titled «Pages» and can be found anywhere between column B and column K.
The sheet where your data is located must be within your current Excel file. This means your data can either be in a different table of cells somewhere in your current spreadsheet, or in a different spreadsheet linked at the bottom of your workbook, as shown below.
For example, if your data is located in «Sheet2» between cells C7 and L18, your table array entry will be «Sheet2!C7:L18.»
5. Enter the column number of the data you want Excel to return.
Beneath the table array field, you’ll enter the «column index number» of the table array you’re searching through. For example, if you’re focusing on columns B through K (notated «B:K» when entered in the «table array» field), but the specific values you want are in column K, you’ll enter «10» in the «column index number» field, since column K is the 10th column from the left.
6. Enter your range lookup to find an exact or approximate match of your lookup value.
In situations like ours, which concerns monthly revenue, you want to find exact matches from the table you’re searching through. To do this, enter «FALSE» in the «range lookup» field. This tells Excel you want to find only the exact revenue associated with each sales contact.
To answer your burning question: Yes, you can allow Excel to look for an approximate match instead of an exact match. To do so, simply enter TRUE instead of FALSE in the fourth field shown above.
When VLOOKUP is set for an approximate match, it’s looking for data that most closely resembles your lookup value, rather than data that is identical to that value. If you’re looking up data associated with a list of website links, for example, and some of your links have «https://» at the beginning, it might behoove you to find an approximate match just in case there are links that do not have this «https://» tag. This way, the rest of the link can match without this initial text tag causing your VLOOKUP formula to return an error if Excel can’t find it.
7. Click ‘Done’ (or ‘Enter’) and fill your new column.
In order to officially bring in the values you want into your new column from Step 1, click «Done» (or «Enter,» depending on your version of Excel) after filling the «range lookup» field. This will populate your first cell. You might take this opportunity to look in the other spreadsheet to make sure this was the correct value.
If so, populate the rest of the new column with each subsequent value by clicking the first filled cell, then clicking the tiny square that appears on the bottom-right corner of this cell. Done! All your values should appear.
VLOOKUP Not Working?
If you’ve followed the above steps and your VLOOKUP is still not working, it will either be an issue with your:
- Syntax (i.e. how you’ve structured the formula)
- Values (i.e. whether the data it’s looking up is good and formatted correctly)
Troubleshooting VLOOKUP Syntax
Start with looking at the VLOOKUP formula that you have written in the designated cell.
- Is it referring to the right lookup value for its key identifier?
- Does it specify the correct table array range for the values it needs to retrieve
- Does it specify the correct sheet for the range?
- Is that sheet spelled correctly?
- Is it using the correct syntax to refer to the sheet? (e.g. Pages!B:K or ‘Sheet 1’!B:K)
- Has the correct column number been specified? (e.g. A is 1, B is 2, and so on)
- Is True or False the correct route for how your sheet is set up?
Troubleshooting VLOOKUP Values
If the syntax is not the problem, how you may have an issue with the values you’re trying to receive themselves. This often manifests as an #N/A error where the VLOOKUP cannot find a referenced value.
- Are the values formatted vertically and from right to left?
- Do the values match how you refer to them?
For example, if you’re looking up URL data, each URL must be a row with its corresponding data to the left of it in the same row. If you have the URLs as column headers with the data moving vertically, the VLOOKUP will not work.
Keeping with this example, the URLs must match in format in both sheets. If you have one sheet including the «https://» in the value while the other sheet omits the «https://», the VLOOKUP will not be able to match the values.
VLOOKUPs as a Powerful Marketing Tool
Marketers have to analyze data from a variety of sources to get a complete picture of lead generation (and more). Microsoft Excel is the perfect tool to do this accurately and at scale, especially with the VLOOKUP function.
Editor’s note: This post was originally published in March 2019 and has been updated for comprehensiveness.
This Excel tutorial explains how to use the VLOOKUP function with syntax and examples.
Description
The VLOOKUP function performs a vertical lookup by searching for a value in the first column of a table and returning the value in the same row in the index_number position.
The VLOOKUP function is a built-in function in Excel that is categorized as a Lookup/Reference Function. It can be used as a worksheet function (WS) in Excel. As a worksheet function, the VLOOKUP function can be entered as part of a formula in a cell of a worksheet.
Subscribe
The VLOOKUP function is actually quite easy to use once you understand how it works! If you want to follow along with this tutorial, download the example spreadsheet.
Download Example
Syntax
The syntax for the VLOOKUP function in Microsoft Excel is:
VLOOKUP( value, table, index_number, [approximate_match] )
Parameters or Arguments
- value
- The value to search for in the first column of the table.
- table
- Two or more columns of data that is sorted in ascending order.
- index_number
- The column number in table from which the matching value must be returned. The first column is 1.
- approximate_match
- Optional. Enter FALSE to find an exact match. Enter TRUE to find an approximate match. If this parameter is omitted, TRUE is the default.
Returns
The VLOOKUP function returns any datatype such as a string, numeric, date, etc.
If you specify FALSE for the approximate_match parameter and no exact match is found, then the VLOOKUP function will return #N/A.
If you specify TRUE for the approximate_match parameter and no exact match is found, then the next smaller value is returned.
If index_number is less than 1, the VLOOKUP function will return #VALUE!.
If index_number is greater than the number of columns in table, the VLOOKUP function will return #REF!.
Example (as Worksheet Function)
Let’s explore how to use VLOOKUP as a worksheet function in Microsoft Excel.
Based on the Excel spreadsheet above, the following VLOOKUP examples would return:
=VLOOKUP(10251, A1:B6, 2, FALSE) Result: "Pears" 'Returns value in 2nd column =VLOOKUP(10251, A1:C6, 3, FALSE) Result: $18.60 'Returns value in 3rd column =VLOOKUP(10251, A1:D6, 4, FALSE) Result: 9 'Returns value in 4th column =VLOOKUP(10248, A1:B6, 2, FALSE) Result: #N/A 'Returns #N/A error (no exact match) =VLOOKUP(10248, A1:B6, 2, TRUE) Result: "Apples" 'Returns an approximate match
Now, let’s look at the example =VLOOKUP(10251, A1:B6, 2, FALSE)
that returns a value of «Pears» and take a closer look why.
First Parameter
The first parameter in the VLOOKUP function is the value to search for in the table of data.
In this example, the first parameter is 10251. This is the value that the VLOOKUP will search for in the first column of the table of data. Because it is a numeric value, you can just enter the number. But if the search value was text, you would need to put it in double quotes, for example:
=VLOOKUP("10251", A1:B6, 2, FALSE)
Second Parameter
The second parameter in the VLOOKUP function is the table or the source of data where the vertical lookup should be performed.
In this example, the second parameter is A1:B6 which gives us two columns to data to use in the vertical lookup — A1:A6 and B1:B6. The first column in the range (A1:A6) is used to search for the Order value of 10251. The second column in the range (B1:B6) contains the value to return which is the Product value.
Third Parameter
The third parameter is the position number in the table where the return data can be found. A value of 1 indicates the first column in the table. The second column is 2, and so on.
In this example, the third parameter is 2. This means that the second column in the table is where we will find the value to return. Since the table range is set to A1:B6, the return value will be in the second column somewhere in the range B1:B6.
Fourth Parameter
Finally and most importantly is the fourth or last parameter in the VLOOKUP. This parameter determines whether you are looking for an exact match or approximate match.
In this example, the fourth parameter is FALSE. A parameter of FALSE means that VLOOKUP is looking for an EXACT match for the value of 10251. A parameter of TRUE means that a «close» match will be returned. Since the VLOOKUP is able to find the value of 10251 in the range A1:A6, it returns the corresponding value from B1:B6 which is Pears.
Exact Match vs. Approximate Match
To find an exact match, use FALSE as the final parameter. To find an approximate match, use TRUE as the final parameter.
Let’s lookup a value that does not exist in our data to demonstrate the importance of this parameter!
Exact Match
Use FALSE to find an exact match:
=VLOOKUP(10248, A1:B6, 2, FALSE) Result: #N/A
If no exact match is found, #N/A is returned.
Approximate Match
Use TRUE to find an approximate match:
=VLOOKUP(10248, A1:B6, 2, TRUE) Result: "Apples"
If no match is found, it returns the next smaller value which in this case is «Apples».
VLOOKUP from Another Sheet
You can use the VLOOKUP to lookup a value when the table is on another sheet. Let’s modify our example above and assume that the table is in a different Sheet called Sheet2 in the range A1:B6.
We could rewrite our original example where we lookup the value 10251 as follows:
=VLOOKUP(10251, Sheet2!A1:B6, 2, FALSE)
By preceding the table range with the sheet name and an exclamation mark, we can update our VLOOKUP to reference a table on another sheet.
VLOOKUP from Another Sheet with Spaces in Sheet Name
Let’s throw in one more complication. What happens if your sheet name contains spaces? If there are spaces in the sheet name, you will need to change the formula further.
Let’s assume that the table is on a Sheet called «Test Sheet» in the range A1:B6, now we need to wrap the Sheet name in single quotes as follows:
=VLOOKUP(10251, 'Test Sheet'!A1:B6, 2, FALSE)
By placing the sheet name within single quotes, we can handle a sheet name with spaces in the VLOOKUP function.
VLOOKUP from Another Workbook
You can use the VLOOKUP to lookup a value in another workbook. For example, if you wanted to have the table portion of the VLOOKUP formula be from an external workbook, we could try the following formula:
=VLOOKUP(10251, 'C:[data.xlsx]Sheet1'!$A$1:$B$6, 2, FALSE)
This would look for the value 10251 in the file C:data.xlxs in Sheet 1 where the table data is found in the range $A$1:$B$6.
Why use Absolute Referencing?
Now it is important for us to cover one more mistake that is commonly made. When people use the VLOOKUP function, they commonly use relative referencing for the table range like we did in some of our examples above. This will return the right answer, but what happens when you copy the formula to another cell? The table range will be adjusted by Excel and change relative to where you paste the new formula. Let’s explain further…
So if you had the following formula in cell G1:
=VLOOKUP(10251, A1:B6, 2, FALSE)
And then you copied this formula from cell G1 to cell H2, it would modify the VLOOKUP formula to this:
=VLOOKUP(10251, B2:C7, 2, FALSE)
Since your table is found in the range A1:B6 and not B2:C7, your formula would return erroneous results in cell H2. To ensure that your range is not changed, try referencing your table range using absolute referencing as follows:
=VLOOKUP(10251, $A$1:$B$6, 2, FALSE)
Now if you copy this formula to another cell, your table range will remain $A$1:$B$6.
How to Handle #N/A Errors
Next, let’s look at how to handle instances where the VLOOKUP function does not find a match and returns the #N/A error. In most cases, you don’t want to see #N/A but would rather display a more user-friendly result.
For example, if you had the following formula:
=VLOOKUP(10248, $A$1:$B$6, 2, FALSE)
Instead of displaying #N/A error if you do not find a match, you could return the value «Not Found». To do this, you could modify your VLOOKUP formula as follows:
=IF(ISNA(VLOOKUP(10248, $A$1:$B$6, 2, FALSE)), "Not Found", VLOOKUP(10248, $A$1:$B$6, 2, FALSE))
OR
=IFERROR(VLOOKUP(10248, $A$1:$B$6, 2, FALSE), "Not Found")
OR
=IFNA(VLOOKUP(10248, $A$1:$B$6, 2, FALSE), "Not Found")
These formulas use the ISNA, IFERROR and IFNA functions to return «Not Found» if a match is not found by the VLOOKUP function.
This is a great way to spruce up your spreadsheet so that you don’t see traditional Excel errors.
Frequently Asked Questions
If you want to find out what others have asked about the VLOOKUP function, go to our Frequently Asked Questions.
Frequently Asked Questions
When you learn the price of the menu below, first your eyes will look up vertically to find your favorite pie, such as The Mushroom Lover. Then your vision slides to the right to find the price for the L size – $27.99.
You’ve just done a vertical lookup, or vlookup. For this purpose, spreadsheet apps including Excel usually provide a specified function called VLOOKUP. In this article, we’ll explore how you can use the Excel VLOOKUP function, check out a few examples, and learn how to troubleshoot it.
What is VLOOKUP in Excel
VLOOKUP stands for vertical lookup. It is a function in Excel that searches vertically a specified value in a column to return a matching value, or values in the same row from different columns.
VLOOKUP syntax in Excel
=VLOOKUP("lookup_value",lookup_range, column_number, [match])
"lookup_value"
is the value you want to look up vertically. Quotes are not used if you reference a cell as a lookup value.lookup_range
is the data range where you’ll search for thelookup_value
and the matching value.column_number
is the number of the column in thelookup_range
, which contains the matching value to return. For example, if your range is D7:G18, D is the first column, E is the second one, and so on.[match]
is the optional parameter to choose either closest or exact match. To return the closest match, specify TRUE; to return an exact match, specify FALSE. The closest match (TRUE) is set by default.
How to VLOOKUP in Excel – formula example
We have the following dataset with the details of courses:
Let’s search for the day when College Writing III is scheduled. Here is the VLOOKUP formula to do this:
=VLOOKUP(A10,A2:H12,6,FALSE)
A10
– the lookup_value “College Writing III“A2:H12
– the lookup_range6
– the column number to return the matching value fromFALSE
– the exact match to return
The result of the schedule for College Writing III is Thursday. And here is how the logic of this VLOOKUP formula looks:
- Excel searches the value of
A10
(College Writing III) in the lookup column (A2:A12
). - If the value is found, Excel moves across the row to column number 6 of the specified data lookup range (
A2:H12
). Column A is the first column in the lookup range, because column A contains the lookup value. - As the formula is set to FALSE (to find the exact match) then the return value is Thursday (you can see the result in A14).
What you should know about VLOOKUP in Excel
- The VLOOKUP function executes a case-insensitive lookup.
- Excel VLOOKUP returns a #N/A if the
lookup_value
is not able to be found inside thelookup_range
. - Excel VLOOKUP returns a
#VALUE!
error if the value ofcolumn_number
is less than 1. - Excel VLOOKUP returns a
#REF!
error if the value of column number is greater than the number of columns in thelookup_range
. - The closest match (TRUE) is specified by default.
How to pull your data to Excel for vertical lookup
The example above is basic for you to understand the logic of the Excel VLOOKUP function. Your cases probably will be more advanced for the data that you can import from different sources to Excel. How? Coupler.io, an integration solution, is designed to export data from multiple apps and sources to Excel or Google Sheets or BigQuery on a schedule. You just need to sign up to Coupler.io and:
- Select and set up a source:
Check out the HubSpot to Excel integration.
- Select and set up a destination (in our case – Microsoft Excel)
- Set up a schedule (optionally) if you want to automate export of your data on a custom schedule.
With your data exported from BigQuery, HubSpot, Xero, etc. to Microsoft Excel, you can easily vlookup it.
How to use VLOOKUP in Excel
There are two ways to access VLOOKUP in Excel – you can use the VLOOKUP formula in the formula bar or access it through the menu bar.
Type directly into the cell
In the example above, we used VLOOKUP in Excel this way. You need to click in the cell where you want the answer to appear, then put the cursor on Formula Bar. Type the VLOOKUP formula and all its parameters directly into the formula bar:
- In the menu bar, select the Formulas tab, then select Lookup & Reference.
- An alphabetical menu will drop down – choose VLOOKUP.
- On your right side, the Formula Builder will appear.
- Fill each box in the Formula Builder as your VLOOKUP formula parameters, then click Done.
Here is how it will look for our Vlookup formula example:
The result is the same – Thursday. So it is up to you which way is easier for you to use the VLOOKUP function 🙂
Excel VLOOKUP for an array
In the Excel VLOOKUP, you can use an array as a lookup_value
. This will let you search the matches for multiple values.
Let’s take the data set from above and vertically look up for the days when the values from the range A14:A20 are scheduled.
Here is the VLOOKUP formula to do this:
=VLOOKUP(A14:A20,Sheet1!A2:H12,6,FALSE)
A14:A20
– the lookup arraySheet1!A2:H12
– the lookup range6
– the column number to return the matching value fromFALSE
– the exact match to return
Excel vlookup cases
Check out the following specific cases of how to vlookup data in Excel:
- How to VLOOKUP for multiple matches
- How to VLOOKUP for two values
- How to VLOOKUP for multiple criteria
- How to compare two columns in Excel using VLOOKUP
- How to VLOOKUP another sheet in Excel
- How to vlookup another workbook/spreadsheet in Excel
- How to vlookup multiple columns in Excel
- Excel SUMIF with VLOOKUP
Excel reverse VLOOKUP
VLOOKUP in Excel can only look up the matching values from left to right.
And what if your data set look like this and you need to look up values from right to left:
Unfortunately, in this case you can’t use VLOOKUP, but the Excel XLOOKUP function will do the job.
Note: The XLOOKUP function is only available in Excel Online and Microsoft 365.
Reverse VLOOKUP syntax
=XLOOKUP("lookup_value", lookup_array, return_array, "[if_not_found]", [match_mode], [search_mode])
lookup_value
is the value you want to look up vertically.lookup_array
is the data array to search thelookup_value
.return_array
is the data array to return the matching value.[if_not_found]
is the optional parameter to return a specified text if thelookup_value
has not been found.[match_mode]
is the optional parameter to choose the match mode:0
– Exact match (default)-1
– If the exact match is not found, the next smallest item is returned.1
– If the exact match is not found, the next largest item is returned.2
– A wildcard match where*
,?
, and~
have special meaning.
[search_mode]
is the optional parameter to choose the search mode:1
– Search starting at the first item (default).-1
– Search starting at the last item.2
– Binary search that relies onlookup_array
being sorted in ascending order. If not sorted, invalid results will be returned.-2
– Binary search that relies onlookup_array
being sorted in descending order. If not sorted, invalid results will be returned.
Reverse VLOOKUP formula example
Let’s search for the day when Lab Only is scheduled. Here is the XLOOKUP formula to do this:
=XLOOKUP("Lab Only",H2:H12,E2:E12,"Not found")
"Lab Only"
– the lookup value.H2:H12
– the data array to search for the lookup valueE2:E12
– the data array to return the matching value."Not found"
– the text to return if the lookup value has not been found.
Another way to do a reverse vlookup is using a combination of the INDEX and MATCH functions, please see this section to learn about these functions.
If your VLOOKUP formula is not working in your Excel
Sometimes when you use VLOOKUP, the #N/A
error message appears. It is the most dreaded and trickiest to handle. Here, we give the five most common reasons why your VLOOKUP is not working, including the solution for each case.
#1: Exact match in the VLOOKUP formula is not specified
Issue
On the following screenshot, we have a VLOOKUP formula, which returns an incorrect result. The correct vlookup result for ID 18 is Apple not Peach.
Solution
Enter FALSE as the last parameter if you are looking for an exact match. The correct VLOOKUP formula is
=VLOOKUP(E3,A2:C8,2,FALSE)
Explanation
The last parameter in the VLOOKUP function is Closest match (TRUE) or Exact match (FALSE). Most people are searching for a certain match such as for customer name, product name or employee name that need an exact match. FALSE should be entered for the last parameter in your VLOOKUP formula when you are looking for an exact value.
#2: The range in the VLOOKUP formula is not locked
Issue
When you drag your working Excel VLOOKUP formula down
=VLOOKUP(E3,A2:C8,2,FALSE)
it returns the #N/A
error.
Solution
You need to lock the range in your VLOOKUP formula before dragging it or copying to other cells. To do this, type $
around the range as shown below:
Your VLOOKUP formula should look like this:
=VLOOKUP(E3,$A$2:$C$8,2,FALSE)
Now you can drag it without any errors expected.
Explanation
Once you dragged your VLOOKUP formula, the range in it changed, which caused the error.
#3: A new column has been inserted to the range
Issue
A new column was inserted and affected the range that was specified in your VLOOKUP formula.
=VLOOKUP(E3,A2:C8,2,FALSE)
Solution
To avoid this in the future, you need to make the column number dynamic using the MATCH function. This allows you to retrieve the matched position of a lookup value and column number. In this way, any new inserted columns won’t affect your VLOOKUP formula.
We updated our formula, so it looks like this.
=VLOOKUP(F3,A2:D8,MATCH(G2,A1:D1,0),FALSE)
G2
– the value to match in lookup range.A1:D1
– the lookup range.0
– exact match type.
Let’s test the new lookup range by adding more columns as shown in the figure below:
The result does not change.
#4: Your table has gotten bigger
Issue
Your VLOOKUP formula was made for a specific limited range. You’ll have to update the formula manually every time when the range grows with new rows. Or not?
Solution
Not only can you set the column dynamic, but also the range, by giving it a name. This will help you ensure your VLOOKUP function always checks the whole table by following these steps:
- Select the range of cells you want to use for the lookup range. Click Home → Format as Table and choose Orange, Table Style Medium 3 (or any other style you desire).
- Specify your lookup range:
$A$1:$C$12
. Check the box My table has headers then click OK as shown in the screenshot below:
- Update your lookup range in the VLOOKUP formula as follows:
Let’s test the new lookup range by adding one more row. Check your VLOOKUP by searching the new ID that you just added to the lookup range. The result returns the correct value as shown in figure below:
#5: Reverse VLOOKUP for those who do not have XLOOKUP in their version of Excel
Issue
The VLOOKUP formula cannot look up a value to the left, and your Excel does not have XLOOKUP.
Solution
You can vlookup to the left using the combination of the INDEX and MATCH functions:
- Suppose you want to look up the ID for Coconut from the table below:
- Type the following formula below in cell F3:
=INDEX(A2:A8,MATCH(E3,B2:B8,0))
INDEX
– a function in Excel that returns the value from a certain location in a range.A2:A8
– the range column where ID is stored is from A2-A8.MATCH
– a function in Excel that used to locate the position of a lookup value in a table/column/row.E3
– where ‘Coconut’ is located.B2:B8
– the range column where Coconut is stored from B2:B8.0
– an exact match of the return value.
- The result is:
Is there any difference between VLOOKUP in Excel and Google Sheets
Basically, VLOOKUP in Excel and Google Sheets has the same logic and the same syntax. So, if you migrate to Excel from Google Sheets, you won’t have any troubles. But of course, there are some differences. Check out our blog post about VLOOKUP in Google Sheets to find them. Good luck with looking up your data!
-
Technical Content Writer on Coupler.io who loves working with data, writing about it, and even producing videos about it. I’ve worked at startups and product companies, writing content for technical audiences of all sorts. You’ll often see me cycling🚴🏼♂️, backpacking around the world🌎, and playing heavy board games.
Back to Blog
Focus on your business
goals while we take care of your data!
Try Coupler.io