Advanced VLOOKUP in Excel_ multiple, double, nested
Advanced VLOOKUP in Excel_ multiple, double, nested
com/office-addins-blog/vlookup-formula-examples/
These examples will teach you how to Vlookup multiple criteria, return a specific instance or all matches, do
dynamic Vlookup in multiple sheets, and more.
It is the second part of the series that will help you harness the power of Excel VLOOKUP. The
examples imply that you know how this function works. If not, it stands to reason to start with the
basic uses of VLOOKUP in Excel.
Now that everyone is on the same page, let's take a closer look at the advanced VLOOKUP formula
examples:
1 of 13 2/15/2025, 3:21 PM
Firefox https://www.ablebits.com/office-addins-blog/vlookup-formula-examples/
Suppose you have a list of orders and want to �nd the quantity based on 2 criteria, Customer name
and Product. A complicating factor is that each customer ordered multiple products, as shown in the
table below:
A usual VLOOKUP formula won't work in this situation because it returns the �rst found match based
on a single lookup value that you specify.
To overcome this, you can add a helper column and concatenate the values from two lookup columns
(Customer and Product) there. It is important that the helper column should be the leftmost column in
the table array because it's where Excel VLOOKUP always searches for the lookup value.
So, add a column to the left of your table and copy the below formula across that column. This will
populate the helper column with the values from columns B and C (the space character is
concatenated in between for better readability):
=B2&" "&C2
And then, use a standard VLOOKUP formula and place both criteria in the lookup_value argument,
separated with a space:
Or, input the criteria in separate cells (G1 and G2 in our case) and concatenate those cells:
As we want to return a value from column D, which is fourth in the table array, we use 4 for
col_index_num. The range_lookup argument is set to FALSE to Vlookup an exact match. The screenshot
below shows the result:
2 of 13 2/15/2025, 3:21 PM
Firefox https://www.ablebits.com/office-addins-blog/vlookup-formula-examples/
In case your lookup table is in another sheet, include the sheet's name in your VLOOKUP formula. For
example:
Alternatively, create a named range for the lookup table (say, Orders) to make the formula easier-to-
read:
For more information, please see How to Vlookup from another sheet in Excel.
Note. For the formula to work correctly, the values in the helper column should be concatenated
exactly the same way as in the lookup_value argument. For example, we used a space character to
separate the criteria in both the helper column (B2&" "&C2) and VLOOKUP formula (G1&" "&G2).
Luckily, Microsoft Excel often provides more than one way to do the same thing. To Vlookup multiple
criteria, you can use either an INDEX MATCH combination or the XLOOKUP function recently
introduced in O�ce 365.
For example, to look up based on 3 di�erent values (Date, Customer name and Product), use one of the
following formulas:
3 of 13 2/15/2025, 3:21 PM
Firefox https://www.ablebits.com/office-addins-blog/vlookup-formula-examples/
Where:
G1 is criteria 1 (date)
G3 is criteria 3 (product)
Note. In all versions except Excel 365, INDEX MATCH should be entered as an CSE array formula by
pressing Ctrl + Shift + Enter. In Excel 365 that supports dynamic arrays it also works as a regular
formula.
4 of 13 2/15/2025, 3:21 PM
Firefox https://www.ablebits.com/office-addins-blog/vlookup-formula-examples/
The simplest way is to add a helper column to the left of the table like we did in the �rst example. But
this time, we will populate it with customer names and occurrence numbers like "John Doe1", "John
Doe2", etc.
To get the occurrence, use the COUNTIF function with a mixed range reference (the �rst reference is
absolute and the second is relative like $B$2:B2). Since the relative reference changes based on a
position of the cell where the formula is copied, in row 3 it will become $B$2:B3, in row 4 - $B$2:B4,
and so on.
Concatenated with the customer name (B2), the formula takes this form:
=B2&COUNTIF($B$2:B2, B2)
The above formula goes to A2, and then you copy it down to as many cells as needed.
After that, input the target name and occurrence number in separate cells (F1 and F2), and use the
below formula to Vlookup a speci�c occurrence:
5 of 13 2/15/2025, 3:21 PM
Firefox https://www.ablebits.com/office-addins-blog/vlookup-formula-examples/
column. Instead, create the table array dynamically by using the INDIRECT function together with
MATCH:
Where:
Please note that the above formula is written for a speci�c case where data cells in the lookup table
begin in row 2. If your table is somewhere in the middle of the sheet, use this universal formula,
where A1 is the top-left cell of the lookup table containing a column header:
The MATCH function con�gured for exact match (0 in the last argument) compares the target name
(E1) against the list of names (A2:A11) and returns the position of the �rst found match, which is 3 in
our case. This number is going to be used as the starting row coordinate for the vlookup range, so we
add 2 to it (+1 to exclude the �rst instance and +1 to exclude row 1 with the column headers).
Alternatively, you can use 1+ROW(A1) to calculate the necessary adjustment automatically based on
the position of the header row (A1 in our case).
6 of 13 2/15/2025, 3:21 PM
Firefox https://www.ablebits.com/office-addins-blog/vlookup-formula-examples/
As the result, we get the following text string, which INDIRECT converts to a range reference:
This range goes to the table_array argument of VLOOKUP forcing it to start searching in row 5, leaving
out the �rst instance of the lookup value:
For example, the below can �nd all occurrences of the lookup value F2 in the lookup range B2:B16 and
return multiple matches from column C:
1. Type the formula in the �rst cell, press Ctrl + Shift + Enter , and then drag it down to a few more
cells.
2. Select several adjacent cells in a single column (F1:F11 in the screenshot below), type the formula
and press Ctrl + Shift + Enter to complete it.
Either way, the number of cells in which you enter the formula should be equal to or larger than the
maximum number of possible matches.
7 of 13 2/15/2025, 3:21 PM
Firefox https://www.ablebits.com/office-addins-blog/vlookup-formula-examples/
For the detailed explanation of the formula logic and more examples, please see How to VLOOKUP
multiple values in Excel.
For this example, we'll take the below table with monthly sales and work out a VLOOKUP formula to
retrieve the sales �gure for a speci�c item in a given month.
With item names in A2:A9, month names in B1:F1, the target item in I1 and the target month in I2, the
formula goes as follows:
MATCH(I2, A1:F1, 0)
Translated into English, the formula says: look up the I2 value in A1:F1 and return its relative position
in the array. By supplying 0 to the 3rd argument, you instruct MATCH to �nd the value exactly equal to
8 of 13 2/15/2025, 3:21 PM
Firefox https://www.ablebits.com/office-addins-blog/vlookup-formula-examples/
the lookup value (it's like using FALSE for the range_lookup argument of VLOOKUP).
Since Mar is in the 4th column in the lookup array, the MATCH function returns 4, which goes directly
to the col_index_num argument of VLOOKUP:
Please pay attention that although the month names start in column B, we use A1:I1 for the lookup
array. This is done in order for the number returned by MATCH to correspond to the column's position
in table_array of VLOOKUP.
To learn more ways to perform matrix lookup in Excel, please see INDEX MATCH MATCH and other
formulas for 2-dimensional lookup.
9 of 13 2/15/2025, 3:21 PM
Firefox https://www.ablebits.com/office-addins-blog/vlookup-formula-examples/
The goal is to copy prices to the main table based on Item IDs. The problem is that the table containing
prices does not have the Item IDs, meaning we will have to do two Vlookups in one formula.
For the sake of convenience, let's create a couple of named ranges �rst:
And now, we will perform the so-called double Vlookup, aka nested Vlookup.
First, make a VLOOKUP formula to �nd the product name in the Lookup table 1 (named Products)
based on the item id (A3):
Next, put the above formula in the lookup_value argument of another VLOOKUP function to pull prices
from Lookup table 2 (named Prices) based on the product name returned by the nested VLOOKUP:
10 of 13 2/15/2025, 3:21 PM
Firefox https://www.ablebits.com/office-addins-blog/vlookup-formula-examples/
pull data from a speci�c sheet depending on the key value in a given cell.
This may be easier to understand from an example. Let's say, you have a few regional sales reports in
the same format, and you are looking to get the sales �gures for a speci�c product in certain regions:
As you can see, all the named ranges have a common part (Sales) and unique parts (CA, FL, KS). Please
be sure to name your ranges in a similar manner as it's essential for the formula we are going to
build.
Input the products of interest in A2 and A3. Those are our lookup values.
Enter the unique parts of the named ranges in B1, C1 and D1.
And now, we concatenate the cell containing the unique part (B1) with the common part ("_Sales"),
and feed the resulting string to INDIRECT:
INDIRECT(B$1&"_Sales")
The INDIRECT function transforms the string into a name that Excel can understand, and you put it in
11 of 13 2/15/2025, 3:21 PM
Firefox https://www.ablebits.com/office-addins-blog/vlookup-formula-examples/
The above formula goes to B2, and then you copy it down and to the right.
Please pay attention that, in the lookup value ($A2), we've locked the column coordinate with absolute
cell reference so that the column remains �xed when the formula is copied to the right. In the B$1
reference, we locked the row because we want the column coordinate to change and supply an
appropriate name part to INDIRECT depending on the column into which the formula is copied:
If your main table is organized di�erently, the lookup values in a row and unique parts of the range
names in a column, then you should lock the row coordinate in the lookup value (B$1) and the column
coordinate in the name parts ($A2):
12 of 13 2/15/2025, 3:21 PM
Firefox https://www.ablebits.com/office-addins-blog/vlookup-formula-examples/
In situation when you have just two or three lookup sheets, you can use a fairly simple VLOOKUP
formula with nested IF functions to select the correct sheet based on the key value in a particular cell:
Where $A2 is the lookup value (item name) and B$1 is the key value (state):
In this case, you do not necessarily need to de�ne names and can use external references to refer to
another sheet or workbook.
For more formula examples, please see How to VLOOKUP across multiple sheets in Excel.
That's how to use VLOOKUP in Excel. I thank you for reading and hope to see you on our blog next
week!
13 of 13 2/15/2025, 3:21 PM