Sie sind auf Seite 1von 12

How to Use VLOOKUPs Range Lookup

Feature
by Matthew Kuo on January 3, 2016

The vast majority of Excel users have never used VLOOKUPs range lookup feature. Most
Excel users familiar with the VLOOKUP formula are just conditioned to know that, when they
get to the range lookup option portion of the VLOOKUP syntax, they should just put in the word
FALSE because they want an exact match. This is because an exact match is what we want
95% of the time were using the VLOOKUP formula, and utilizing the range lookup option is
just not a common requirement.
Today, well walk through how you can actually utilize this feature of the VLOOKUP
formula. As mentioned before, the Range Lookups lack of prevalence is mainly due to the lack
of situations that require it. However, one key
situation does exist:
The Range Lookup feature of VLOOKUP can be used as an alternative to writing a Nested
IF Statement
Click here to download an example Excel file using VLOOKUPs Range Lookup Feature

The Nested IF Formula

A Nested IF Statement is an Excel formula with multiple IF Statements embedded inside of


it. Nested IF Statements are used for two primary purposes:

Assigning data values to a set of categories


Assigning data values to histogram bins

While writing a Nested IF formula is a very popular approach to address these requirements,
there are a number of issues that make using it difficult. Nested IF formulas are difficult to
write, prone to errors, and not scalable if you have several categories or bins.

When you use VLOOKUPs Range Lookup feature as an alternative to using a Nested IF, it
solves the majority of these problems:

VLOOKUP is simpler and much easier to write


Because its simpler to write, its much less prone to errors
The VLOOKUP approach is scalable because the formula does not increase in length as
you add more categories and bins

However, the VLOOKUP formulas Range Lookup is definitely less flexible than a Nested IF, as
there are certain specifications you need to ensure are in place before you can use it.

Requirements for Using VLOOKUPs Range Lookup


Feature
Assume we want to use VLOOKUPs Range Lookup to assign a set of data values to a smaller
set of categories. Assume each category has a minimum value and a maximum value. In order
to make VLOOKUP work, we need to ensure the following specifications are in place:

The full range of categories needs to be continuous there shouldnt be any breaks
between one categorys maximum and the next categorys minimum

Your category minimums must be sorted in ascending order they need to go up


sequentially from smallest to largest
Your category minimums need to be on the left hand side of your table VLOOKUP
performs lookups on the left hand side of your table and will be looking up off of your
minimums
Your category names need to be to the right because your category names are your
return column, and VLOOKUP performs a left to right lookup, they need to be to the
right of your lookup values (category minimums)
Your minimum threshold has to be greater than or equal to that minimum it
cannot be just greater than because of VLOOKUPs exact match logic

Its difficult to digest these criteria without context, so well go through an audit of our setup to
ensure that these conditions are met during the actual exercise.
Click here to download an example Excel file using VLOOKUPs Range Lookup Feature
Step 1: Define the categories you want to assign your data set values to
The first step of this category assignment process will be to define the objective. In the
following example, our objective is to assign each number in our data set to one of three
categories:

Low
Medium
High

Based on the following criteria:

Low is from 0 to less than 30


Medium is from 30 to less than 60
High is any value 60 or greater

For simplification purposes well assume that our data set does not contain negative numbers.
Step 2: Setup your criteria table based on the requirements for VLOOKUPs range lookup
feature
The simplest way to complete this process is to put all of your categories and criteria in a simple
table detailing the minimum and maximum for each category. See below for an example based
on the conditions weve identified:

Now well go through an audit of each of the specifications we identified before to make sure
our setup of the criteria is appropriate for use with VLOOKUPs Range Lookup:

The full range of categories needs to be continuous check


Your category minimums must be sorted in ascending order check
Your category minimums need to be on the left hand side of your table check
Your category names need to be to the right check, note that this is somewhat
unintuitive as generally, wed put the category names before any of the numbers
Your minimum threshold has to be greater than or equal to that minimum check;
note in the upper left category Ive denoted the minimums as (>=)

Since our setup is correct, we can now begin the category assignment process using VLOOKUP.
Step 3: Load your Data Set
Load your data into a single vertical column (highlighted in yellow below) and add a field next
to it to assign it to a category.

Step 4: Start Writing your Category Assignment Formula using VLOOKUP


The syntax for the VLOOKUP formula is as follows:
= VLOOKUP ( lookup_value, table_array , col_index_num , [ range_lookup ] )
Remember that were not doing a lookup in the traditional sense here, where wed want to find
an exact match to our lookup number. Were instead utilizing the range lookup and we only
need to change a portion of the syntax to do so.
Click here for a tutorial on VLOOKUP using the more common exact match option
Step 5: Select your first data set value as the lookup value
This is the value we want to assign a category to.

Step 6: Select the criteria table as your table array and remember to reference lock it
Hit the F4 Key right after selecting your criteria table to reference lock it.

Step 7: Reference the Category Name using the column reference


Because our category name is in the third column of our table array, well input the number 3.

Step 8: Enter TRUE to enable VLOOKUPs Range Lookup feature


This is the key that makes VLOOKUP work in this particular use case. You could also just leave
this part of the syntax blank to have it activate range lookup, but for the purposes of this tutorial,
well be explicit about what type of lookup we want.

Step 9: Copy the formula down


Before doing this, look back to Step 5 and make sure that you reference locked your table array
before doing this. If this is already done, just double click in the lower right corner of the cell for
the formula you just wrote, and the cells will copy down for you.

We now have assigned all of our values to a specific category using the VLOOKUP formula.

How it Works
When you review VLOOKUPs documentation from Microsoft, youll see that you have two
options when you get to the range lookup portion of the syntax:
Input
0 or FALSE
1 or TRUE or leave blank

Result
VLOOKUP does an exact match
VLOOKUP does an approximate match

You can see that for the very last option, which we are utilizing in our example, VLOOKUP
does an approximate match. VLOOKUPs range lookup works exactly the same as the MATCH
formulas approximate match option. While Microsoft Excels documentation is very explicit
about the approximate match logic when describing the MATCH formula, for VLOOKUP it
feels somewhat hidden away. Therefore, lets go into the specifics of what Excel does during an
approximate match:

If an exact match is found Excel performs an exact match VLOOKUP.


If an exact match is not found Excel returns the next largest value that is less than the
lookup value.

To see how it works, well work through the logic that a range lookup goes through:

Excel looks for the next largest value within the left hand column of our table array
that is still less than our lookup value. Because each of our category ranges are
continuous (there are no breaks between them) this logic works out to be the exact same
as looking for the category minimum of each of our lookup values.

For 42, the category minimum is 30, because 30 is the next largest number less than 42.
Once Excel knows which number to lock on to, it uses VLOOKUP to return the
corresponding value in the third column of the overall table array, which is Medium
Medium will be the category name for 42

Just for the sake of completeness, lets run through a scenario where we tell Excel to do a range
lookup, but we get an exact match:

For the number 60, the category minimum is 60, because when an exact match is found,
Excel just does an exact match VLOOKUP
Once Excel knows which number to lock on to, it uses VLOOKUP to return the
corresponding value in the third column of the overall table array, which is High
High will be the category name for 60

Click here to download an example Excel file using VLOOKUPs Range Lookup Feature

Conclusion
The Range Lookup feature of VLOOKUP remains a mystery to most Excel users in
world. However, one specific use case does exist and based on our example, it turns out to be a
much better option than using a Nested IF Statement. While VLOOKUPs Range Lookup does
have very specific setup conditions you need to put in place before you can use it, it ends up
being much easier to write, less prone to errors, and much more scalable than a Nested IF. While
its still not a common need, its worthwhile to learn VLOOKUPs Range Lookup just to have
this in your back pocket.

Das könnte Ihnen auch gefallen