Vlookup Formuals
Vlookup Formuals
Equal to | Greater than | Less than | Greater than or equal to | Less than or equal to |
Not equal to
Use comparison operators in Excel to check if two values are equal to each other, if one
value is greater than another value, if one value is less than another value, etc.
Equal to
The equal to operator (=) returns TRUE if two values are equal to each other.
1. For example, take a look at the formula in cell C1 below.
Explanation: the formula returns TRUE because the value in cell A1 is equal to the value
in cell B1. Always start a formula with an equal sign (=).
Explanation: if the two values (numbers or text strings) are equal to each other, the IF
function returns Yes, else it returns No.
Greater than
The greater than operator (>) returns TRUE if the first value is greater than the second
value.
1. For example, take a look at the formula in cell C1 below.
Explanation: the formula returns TRUE because the value in cell A1 is greater than the
value in cell B1.
Explanation: this OR function returns TRUE if at least one value is greater than 50, else
it returns FALSE.
Less than
The less than operator (<) returns TRUE if the first value is less than the second value.
1. For example, take a look at the formula in cell C1 below.
Explanation: the formula returns TRUE because the value in cell A1 is less than the
value in cell B1.
Explanation: the formula returns TRUE because the value in cell A1 is greater than or
equal to the value in cell B1.
2. The COUNTIF function below uses the greater than or equal to operator.
Explanation: this COUNTIF function counts the number of cells that are greater than or
equal to 10.
Less than or equal to
The less than or equal to operator (<=) returns TRUE if the first value is less than or
equal to the second value.
1. For example, take a look at the formula in cell C1 below.
Explanation: the formula returns TRUE because the value in cell A1 is less than or equal
to the value in cell B1.
2. The SUMIF function below uses the less than or equal to operator.
Explanation: this SUMIF function sums values in the range A1:A5 that are less than or
equal to 10.
Not Equal to
The not equal to operator (<>) returns TRUE if two values are not equal to each other.
1. For example, take a look at the formula in cell C1 below.
Explanation: the formula returns TRUE because the value in cell A1 is not equal to the
value in cell B1.
Explanation: if the two values (numbers or text strings) are not equal to each other,
the IF
Cell References
Relative Reference | Absolute Reference | Mixed Reference
Cell references in Excel are very important. Understand the difference between relative,
absolute and mixed reference, and you are on your way to success.
Relative Reference
By default, Excel uses relative references. See the formula in cell D2 below. Cell D2
references (points to) cell B2 and cell C2. Both references are relative.
1. Select cell D2, click on the lower right corner of cell D2 and drag it down to cell D5.
Cell D3 references cell B3 and cell C3. Cell D4 references cell B4 and cell C4. Cell D5
references cell B5 and cell C5. In other words: each cell references its two neighbors on
the left.
Absolute Reference
See the formula in cell E3 below.
1. To create an absolute reference to cell H3, place a $ symbol in front of the column
letter and row number ($H$3) in the formula of cell E3.
Mixed Reference
Sometimes we need a combination of relative and absolute reference (mixed
reference).
1. See the formula in cell F2 below.
2. We want to copy this formula to the other cells quickly. Drag cell F2 across one cell,
and look at the formula in cell G2.
Do you see what happens? The reference to the price should be a fixed reference to
column B. Solution: place a $ symbol in front of the column letter ($B2) in the formula of
cell F2. In a similar way, when we drag cell F2 down, the reference to the reduction
should be a fixed reference to row 6. Solution: place a $ symbol in front of the row
number (B$6) in the formula of cell F2.
Result:
Note: we don't place a $ symbol in front of the row number of $B2 (this way we allow
the reference to change from $B2 (Jeans) to $B3 (Shirts) when we drag the formula
down). In a similar way, we don't place a $ symbol in front of the column letter of B$6
(this way we allow the reference to change from B$6 (Jan) to C$6 (Feb) and D$6 (Mar)
when we drag the formula across).
Note: use the MONTH and DAY function to get the month and day of a date.
Date Function
1. To add a number of days to a date, use the following simple formula.
2. To add a number of years, months and/or days, use the DATE function.
Note: the DATE function accepts three arguments: year, month and day. Excel knows
that 6 + 2 = 8 = August has 31 days and rolls over to the next month (23 August + 9
days = 1 September).
Note: use the MINUTE and SECOND function to return the minute and second.
Time Function
To add a number of hours, minutes and/or seconds, use the TIME function.
Text Functions
Join Strings | Left | Right | Mid | Len | Find | Substitute
Excel has many functions to offer when it comes to manipulating text strings.
Join Strings
To join strings, use the & operator.
Note: instead of using the & operator, use the CONCATENATE function in Excel.
Left
To extract the leftmost characters from a string, use the LEFT function.
Right
To extract the rightmost characters from a string, use the RIGHT function.
Mid
To extract a substring, starting in the middle of a string, use the MID function.
Len
To get the length of a string, use the LEN function.
Find
To find the position of a substring in a string, use the FIND function.
Note: string "am" found at position 3. Visit our page about the FIND function for more
examples.
Substitute
To replace existing text with new text in a string, use the SUBSTITUTE function.
Match
The MATCH function returns the position of a value in a given range.
Explanation: Yellow found at position 3 in the range E4:E7. The third argument is
optional. Set this argument to 0 to return the position of the value that is exactly equal
to lookup_value (A2) or a #N/A error if not found. Use INDEX and MATCH in Excel and
impress your boss.
Index
The INDEX function below returns a specific value in a two-dimensional range.
Explanation: 92 found at the intersection of row 3 and column 2 in the range E4:F7.
Explanation: 97 found at position 3 in the range E4:E7. Use INDEX and MATCH in Excel
and impress your boss.
Choose
The CHOOSE function returns a value from a list of values, based on a position number.
Explanation: Boat found at position 3.
Vlookup
Exact Match | Approximate Match | Vlookup Looks Right | First Match | Vlookup is Case-
insensitive | Multiple Criteria | #N/A error | Multiple Lookup Tables | Index and Match
The VLOOKUP function is one of the most popular functions in Excel. This page contains
many easy to follow VLOOKUP examples.
Exact Match
Most of the time you are looking for an exact match when you use the VLOOKUP
function in Excel. Let's take a look at the arguments of the VLOOKUP function.
1. The VLOOKUP function below looks up the value 53 (first argument) in the leftmost
column of the red table (second argument).
2. The value 4 (third argument) tells the VLOOKUP function to return the value in the
same row from the fourth column of the red table.
Note: the Boolean FALSE (fourth argument) tells the VLOOKUP function to return an
exact match. If the VLOOKUP function cannot find the value 53 in the first column, it will
return a #N/A error.
3. Here's another example. Instead of returning the salary, the VLOOKUP function below
returns the last name (third argument is set to 3) of ID 79.
Approximate Match
Let's take a look at an example of the VLOOKUP function in approximate match mode
(fourth argument set to TRUE).
1. The VLOOKUP function below looks up the value 85 (first argument) in the leftmost
column of the red table (second argument). There's just one problem. There's no value
85 in the first column.
2. Fortunately, the Boolean TRUE (fourth argument) tells the VLOOKUP function to
return an approximate match. If the VLOOKUP function cannot find the value 85 in the
first column, it will return the largest value smaller than 85. In this example, this will be
the value 80.
3. The value 2 (third argument) tells the VLOOKUP function to return the value in the
same row from the second column of the red table.
Note: always sort the leftmost column of the red table in ascending order if you use the
VLOOKUP function in approximate match mode (fourth argument set to TRUE).
2. If you change the column index number (third argument) to 3, the VLOOKUP function
looks up the first name and returns the salary.
Note: in this example, the VLOOKUP function cannot lookup the first name and return
the ID. The VLOOKUP function only looks to the right. No worries, you can use the INDEX
and the MATCH function in Excel to perform a left lookup.
First Match
If the leftmost column of the table contains duplicates, the VLOOKUP function matches
the first instance. For example, take a look at the VLOOKUP function below.
Explanation: the VLOOKUP function returns the salary of Mia Clark, not Mia Reed.
Vlookup is Case-insensitive
The VLOOKUP function in Excel performs a case-insensitive lookup. For example, the
VLOOKUP function below looks up MIA (cell G2) in the leftmost column of the table.
Explanation: the VLOOKUP function is case-insensitive so it looks up MIA or Mia or mia
or miA, etc. As a result, the VLOOKUP function returns the salary of Mia Clark (first
instance). You can use the INDEX, MATCH and the EXACT function in Excel to perform
a case-sensitive lookup.
Multiple Criteria
Do you want to look up a value based on multiple criteria? Use the INDEX and the
MATCH function in Excel to perform a two-column lookup.
Note: the array formula above looks up the salary of James Clark, not James Smith, not
James Anderson.
#N/A error
If the VLOOKUP function cannot find a match, it returns a #N/A error.
1. For example, the VLOOKUP function below cannot find the value 28 in the leftmost
column.
2. If you like, you can use the IFNA function to replace the #N/A error with a friendly
message.
Note: the IFNA function was introduced in Excel 2013. If you're using Excel 2010 or
Excel 2007, simply replace IFNA with IFERROR. Remember, the IFERROR function
catches other errors as well. For example, the #NAME? error if you accidentally misspell
the word VLOOKUP.
Explanation: the bonus depends on the market (UK or USA) and the sales amount. The
second argument of the VLOOKUP function does the trick. If UK, the VLOOKUP function
uses Table1, if USA, the VLOOKUP function uses Table2. Set the fourth argument of the
VLOOKUP function to TRUE to return an approximate match.
3. Press Enter.
4. Select cell E4, click on the lower right corner of cell E4 and drag it down to cell E10.
Note: for example, Walker receives a bonus of $1,500. Because we're using named
ranges, we can easily copy this VLOOKUP function to the other cells without worrying
about cell references.
Taxable
Tax on this income
income
0 - $18,200 Nil
$18,201 -
19c for each $1 over $18,200
$37,000
Example: if income is 39000, tax equals 3572 + 0.325 * (39000 - 37000) = 3572 + 650
= $4222
Explanation: Excel cannot find 39000 in the first column of Rates. However, it can find
37000 (the largest value smaller than 39000). As a result, it returns 3572
(col_index_num, the third argument, is set to 2).
3. Now, what's left is the remainder of the equation, + 0.325 * (39000 - 37000). This is
easy. We can return 0.325 by setting col_index_num to 3 and return 37000 by setting
col_index_num to 1. The complete formula below does the trick.
Note: when you set the fourth argument of the VLOOKUP function to TRUE, the first
column of the table must be sorted in ascending order.
Index and Match
Match | Index | Index and Match | Two-way Lookup | Case-sensitive Lookup | Left Lookup
| Two-column Lookup | Closest Match
Use INDEX and MATCH in Excel and impress your boss. Instead of using VLOOKUP, use
INDEX and MATCH. To perform advanced lookups, you'll need INDEX and MATCH.
Match
The MATCH function returns the position of a value in a given range. For example, the
MATCH function below looks up the value 53 in the range B3:B9.
Index
The INDEX function below returns a specific value in a one-dimensional range.
Explanation: the INDEX function returns the 5th value (second argument) in the range
E3:E9 (first argument).
Explanation: the MATCH function returns position 5. The INDEX function needs position
5. It's a perfect combination. If you like, you can also use the VLOOKUP function. It's up
to you. However, you'll need INDEX and MATCH to perform advanced lookups, as we will
see next.
Two-way Lookup
The INDEX function can also return a specific value in a two-dimensional range. For
example, use the INDEX and the MATCH function in Excel to perform a two-way-lookup.
Case-sensitive Lookup
By default, the VLOOKUP function performs a case-insensitive lookup. However, you can
use the INDEX, MATCH and the EXACT function in Excel to perform a case-sensitive
lookup.
Note: the formula correctly looks up the salary of MIA Reed, not Mia Clark.
Left Lookup
The VLOOKUP function only looks to the right. No worries, you can use the INDEX and
the MATCH function in Excel to perform a left lookup.
Note: when we drag this formula down, the absolute references ($E$4:$E$7 and
$G$4:$G$7) stay the same, while the relative reference (A2) changes to A3, A4, A5, etc.
Two-column Lookup
Do you want to look up a value based on multiple criteria? Use the INDEX and the
MATCH function in Excel to perform a two-column lookup.
Note: the array formula above looks up the salary of James Clark, not James Smith, not
James Anderson.
Closest Match
To find the closest match to a target value in a data column, use the INDEX, MATCH,
ABS and the MIN function in Excel.
Two-way Lookup
This example teaches you how to lookup a value in a two-dimensional range. We use
the INDEX and the MATCH function in Excel.
Below you can find the sales of different ice cream flavors in each month.
1. To find the position of Feb in the range A2:A13, use the MATCH function. The result is
2.
2. To find the position of Chocolate in the range B1:D1, use the MATCH function. The
result is 1.
3. Use these results and the INDEX function to find the sales of Chocolate in February.
Explanation: 217 found at the intersection of row 2 and column 1 in the range B2:D13.
Offset
The OFFSET function in Excel returns a cell or range of cells that is a specified number
of rows and columns from a cell or range of cells.
1. The OFFSET function below returns the cell that is 3 rows below and 2 columns to the
right of cell A2. The OFFSET function returns a cell because the height and width are
both set to 1.
Result:
2. The OFFSET function below returns the 1 x 2 range that is 8 rows below and 1 column
to the right of cell A2. The SUM function calculates the sum of this range.
Result:
The last 2 arguments of the OFFSET function are optional. When height and width are
omitted, the new reference has the same height and width as the starting reference
(first argument). As always, we will use easy examples to make things more clear.
3. The OFFSET function below returns the cell that is 12 rows below and 0 columns to
the right of cell A2.
Result:
4. The OFFSET function below returns the range that is 4 rows below and 0 columns to
the right of the range B2:C2. The SUM function calculates the sum of this range.
Result:
Note: to return a range (without calculating the sum), select a range of the same size
before you insert the OFFSET function and finish by pressing CTRL + SHIFT + ENTER. If
you want to return a cell or range of cells that is a specified number of rows above or
columns to the left, enter a negative number.
Case-sensitive Lookup
By default, the VLOOKUP function performs a case-insensitive lookup. However, you can
use the INDEX, MATCH and the EXACT function in Excel to perform a case-sensitive
lookup.
1. For example, the simple VLOOKUP function below returns the salary of Mia Clark.
However, we want to lookup the salary of MIA Reed (see cell G2).
2. The EXACT function in Excel returns TRUE if two strings are exactly the same. The
EXACT function below returns FALSE.
3. The EXACT function below returns TRUE.
{FALSE;FALSE;FALSE;FALSE;FALSE;TRUE;FALSE}
5. All we need is a function that finds the position of TRUE in this array constant. MATCH
function to the rescue! Finish by pressing CTRL + SHIFT + ENTER.
Explanation: TRUE (first argument) found at position 6 in the array constant (second
argument). In this example, we use the MATCH function to return an exact match so we
set the third argument to 0. The formula bar indicates that this is an array formula by
enclosing it in curly braces {}. Do not type these yourself.
6. Use the INDEX function (two arguments) to return a specific value in a one-
dimensional range. In this example, the salary at position 6 (second argument) in the
range D3:D9 (first argument).
Note: the formula correctly looks up the salary of MIA Reed, not Mia Clark. The formula
bar indicates that this is an array formula by enclosing it in curly braces {}.
Left Lookup
The VLOOKUP function only looks to the right. To look up a value in any column and
return the corresponding value to the left, simply use the INDEX and
the MATCH function.
1. The MATCH function returns the position of a value in a given range.
2. Use this result and the INDEX function to return the 4th value in the range
$E$4:$E$7.
3. Drag the formula in cell B2 down to cell B11.
Note: when we drag this formula down, the absolute references ($E$4:$E$7 and
$G$4:$G$7) stay the same, while the relative reference (A2) changes to A3, A4, A5, etc.
2. Second, we use the MATCH function to find the row number of the maximum value.
Explanation: the MATCH function reduces to =MATCH(12,A:A,0), 7. The MATCH function
returns the position of the maximum value in column A. Set the third argument to 0 to
return an exact match.
Indirect
Cell Reference | Range Reference | Named Range | Worksheet Reference
Use the INDIRECT function in Excel to convert a text string into a valid reference. You
can use the & operator to create text strings.
Cell Reference
Use the INDIRECT function in Excel to convert a text string into a valid cell reference.
2. The simple INDIRECT function below produces the exact same result.
3. Do we really need the INDIRECT function? Yes. Without using the INDIRECT function,
this would be the result.
4. Use the & operator to join the string "D" with the value in cell A1.
Range Reference
Use the INDIRECT function in Excel to convert a text string into a valid range reference.
For example, combine the SUM function and the INDIRECT function.
Named Range
Use the INDIRECT function in Excel to convert a text string into a valid named range.
1. For example, the AVERAGE function below uses the named range Scores.
Worksheet Reference
Use the INDIRECT function in Excel to create a dynamic worksheet reference.
Note: cell A1 on Sheet1 contains the value 10. Cell A1 on Sheet2 contains the value 20.
Cell A1 on Sheet3 contains the value 30.
2. On the Summary sheet, enter the INDIRECT function shown below. Use the &
operator to join the sheet name in cell A1 with "!A1".
Explanation: the formula above reduces to =INDIRECT("Sheet1!A1"). The INDIRECT
function converts the text string "Sheet1!A1" into a valid worksheet reference. In other
words, =INDIRECT("Sheet1!A1") reduces to =Sheet1!A1.
3. If your sheet names contain spaces or other special characters, enclose the sheet
name in single quotation marks. Modify the INDIRECT function as shown below.
Two-column Lookup
This example teaches you how to perform a two-column lookup in Excel. See the
example below. We want to look up the salary of James Clark, not James Smith, not
James Anderson.
1. To join strings, use the & operator.
2. The MATCH function returns the position of a value in a given range. Insert the
MATCH function shown below.
{"JamesSmith";"JamesAnderson";"JamesClark";"JohnLewis";"JohnWalker";"MarkReed";"Ri
chardLopez"}
This array constant is used as an argument for the MATCH function, giving a result of 3
(JamesClark found at position 3).
4. Use this result and the INDEX function to return the 3rd value in the range C2:C8.
Closest Match
To find the closest match to a target value in a data column, use the INDEX, MATCH,
ABS and the MIN function in Excel. Use the VLOOKUP function in Excel to find an
approximate match.
1. The ABS function in Excel returns the absolute value of a number.
Explanation: C3-F2 equals -39. The ABS function removes the minus sign (-) from a
negative number, making it positive. The ABS function has no effect on 0 (zero) or
positive numbers.
2. To calculate the differences between the target value and the values in the data
column, replace C3 with C3:C9.
Explanation: the range (array constant) created by the ABS function is stored in Excel's
memory, not in a range. The array constant looks as follows:
{39;14;37;16;22;16;17}
3. To find the closest match, add the MIN function and finish by pressing CTRL + SHIFT
+ ENTER.
Note: the formula bar indicates that this is an array formula by enclosing it in curly
braces {}. Do not type these yourself. The array constant is used as an argument for
the MIN function, giving a result of 14.
4. All we need is a function that finds the position of the value 14 in the array constant.
MATCH function to the rescue! Finish by pressing CTRL + SHIFT + ENTER.
Display Duplicates
Let's start by comparing two columns and displaying the duplicates.
1. Display the duplicates in the first column (these values also occur in the second
column).
Explanation: the MATCH function in cell C1 returns the number 5 (letter A found at
position 5 in the range B1:B7). As a result, the ISERROR function returns FALSE and the
IF function returns the value in cell A1. The MATCH function in cell C4 returns a #N/A
error (no letter D in the range B1:B7). As a result, the ISERROR function returns TRUE
and the IF function returns an empty string.
Note: at step 1, we matched each value in the first column with the range in the second
column. At step 2, we match each value in the second column with the range in the first
column.
1. Display the unique values in the first column (these values do not occur in the second
column).
Note: take a look at the first picture on this page to see that we simply swapped the last
2 arguments of the IF function.
2. You can also display the unique values in the second column.
Note: take a look at the second picture on this page to see that we simply swapped the
last 2 arguments of the IF function.
3. Do you want to compare two columns by highlighting the unique values in each
column? Visit our page about comparing two lists.
Row by Row Comparison
For a quick row by row comparison, simply use the IF function in Excel.
1. The IF function in cell C1 below returns Match because the value in cell A1 is equal to
the value in cell B1.