Broad Strokes
Well implemented lookups make models significantly more flexible
Lookup formulas are one of the greatest features of Excel. When working across more than one database, these formulas can be used to translate between the two and retrieve relevant data automatically (e.g., corresponding to a time period, category, etc.). When these are well implemented, it will add a new level of agility to the model.
Usage and Style
There are four types of lookup formulas in Excel:
INDEX(MATCH)), LOOKUP(), VLOOKUP(), and HLOOKUP().
Of these four, I strongly recommend using INDEX(MATCH()) for almost everything. Occasionally, LOOKUP() comes in handy when using array formulas. Although VLOOKUP() and HLOOKUP() are not recommended, this article digs into the alternatives as well. Because these are commonly used formulas, it’s advisable to adhere to established technical conventions if you’re working in an existing/shared workbook. You may also want to avoid the use of array formulas for client-facing applications.
When building an application from scratch, however, there are four good reasons to stick with the preferred INDEX(MATCH()) and LOOKUP() formulas:
- Under most circumstances, the combination of INDEX() and MATCH() formulas offers more functionality than LOOKUP(), VLOOKUP(), or HLOOKUP(), with consistent syntax in all applications.
- With a little help from the TRANSPOSE() array formula, INDEX(MATCH()) can perform two-dimensional lookups on a table, providing the combined functionality of VLOOKUP() and HLOOKUP().
- VLOOKUP() uses a hard-coded integer to specify the offset of the lookup column relative to the reference column. This means that VLOOKUP() will not read the intended data if you add or delete a column between the reference and lookup columns. Ditto for HLOOKUP() and its references to rows.
- INDEX(MATCH()), VLOOKUP(), and HLOOKUP() do not play nicely with array formulas, which leaves only LOOKUP() for this particular situation.
When using array formulas, the lesser-known LOOKUP() is the only option available. This formula is similar to VLOOKUP() but offers the advantage of using direct cell references to assign the reference and lookup columns in the formula. Unfortunately, LOOKUP() lacks the ‘exact match’ option that is available in all three of the alternatives, so you’ll need to make sure that your reference column is sorted in ascending numerical/alphabetical/chronological order.
Syntax
Click the following buttons to read more about each formula.
Looks up data based on column and/or row headings – recommended for most applications
Use if necessary: Looks up tabulated data based on row headings – data must be sorted.
Not recommended: Looks up tabulated data based on row headings – less robust than INDEX(MATCH()).
Not recommended: Looks up tabulated data based on column headings – less robust than INDEX(MATCH()).
Examples
The excel file embedded below demonstrates the use of all four formulas to perform the same set of tasks. Notice that it is possible to use each formula to do almost anything, although only the INDEX(MATCH()) option uses consistent syntax across every application.
All of the example formulas listed here look up data from the named table at the top of the sheet.
Note that the examples here are not exhaustive – it’s possible to add other formulas (like TRANSPOSE(), MATCH(), OFFSET(), INDIRECT(), etc.) that will allow most of these lookup formulas to perform any stated function. The intent here is to compare how each formula would reasonably be used in real-world applications.