Microsoft Excel Diploma Course
Microsoft Excel is an integral part of the business landscape and it is a critical...
One of the most useful functions available in Excel is the LOOKUP function. This allows you to take any value entered, find it in a data range, then return a value or information from that same data range without having to scroll through a list.
The most commonly used LOOKUP functions in Excel are VLOOKUP and HLOOKUP. VLOOKUP allows you to search a data range that is set up vertically. HLOOKUP is the exact same function, but looks up data that has been formatted by rows instead of columns.
LOOKUP and related functions are commonly used for business analytics in Excel as a way of slicing and dicing data for analysis. We also cover this topic in our Excel training courses.
VLOOKUP and HLOOKUP functions have certain drawbacks that could lead to potential errors, especially for users who are often unfamiliar with the spreadsheet or financial model. These issues will be discussed in this tutorial, together with a simple LOOKUP function which could be used to replace the VLOOKUP/HLOOKUP in the model.
In certain cases, especially when there is an unsorted range, a combination of INDEX and MATCH functions could be a more robust solution than the LOOKUP functions. Our downloadable workbook illustrates these concepts – see links at the top or bottom of this page.
INDEX(MATCH) can be a more powerful solution in financial models than the traditional VLOOKUP/HLOOKUP, and can be used to increase the robustness of models in more advanced situations, such as our LBO financial modelling courses and advanced project finance modelling courses.
Detailed examples of VLOOKUP, HLOOKUP, LOOKUP and INDEX(MATCH)
VLOOKUP searches for a value in the leftmost column of a data range, and then returns a value in the same row from a column you specify in the range. VLOOKUP is used instead of HLOOKUP when your comparison values are located in a column to the left of the data you want to find.
The syntax for VLOOKUP is VLOOKUP (lookup_value, table_array, col_index_num, range_lookup)
‘range_lookup’: If TRUE (or omitted), an approximate match is returned (i.e., if an exact match is not found, the next largest value that is less than ‘lookup_value’ is returned). If FALSE, VLOOKUP will find an exact match.
As an example, price data is shown in screenshot 1. The first column in the data table is the price case; the next few columns includes respective information; and the remaining columns are for the periodic price data for each calendar year.
VLOOKUP formula is used to solve as shown in the screenshot. The “col_index_num” for the price in period CY2023 would be “4”, for period CY2024 would be “5” and so on. Please note that the “FALSE” is included in the “range_lookup” in this example because the data in the first column is unsorted.
HLOOKUP performs the same function as VLOOKUP, but looks up data that has been formatted by rows. HLOOKUP searches for a value in the top row of a table (or an array of values), and then returns a value in the same column from a row you specify in the table or array.
The syntax for HLOOKUP is HLOOKUP (lookup_value, table_array, row_index_num, range_lookup)
Use caution if any columns or rows are inserted, moved or deleted:
VLOOKUP could only search for a value in the first leftmost column of a data range. Similarly, HLOOKUP could only search for a value in the top row of the range:
Values in the first column/row of the data range need to be sorted if range_lookup is ‘TRUE’ (or omitted), unless the range_lookup is ‘FALSE’:
The VLOOKUP/HLOOKUP functions are often used before a LOOKUP function. However, the LOOKUP function is far cleaner and more transparent, as it only requires two ranges and a LOOKUP value. The syntax for LOOKUP is LOOKUP (lookup_value, lookup_vector, result_vector).
However for the example in screenshot 2, you can see quite clearly that the LOOKUP function will not be appropriate as the lookup_vector is text and not sorted in ascending (A to Z) order. As LOOKUP will return the next smallest match where a result cannot be found, it returns the “Base case”: L comes after H in the alphabet, so B is the next smallest result in this instance.
Although for the example in screenshot 2 this is not satisfactory, the method of matching is advantageous in certain situations. If the lookup_vector is a number which is sorted in ascending order (e.g., the model timeline which progresses left-to-right), we are able to use this to minimise the number of inputs required.
As you can see in screenshot 3, the lookup_value is our calendar year counter, an ascending counter from the start to the end of the model timeline. Therefore, LOOKUP is an effective method to return the corresponding price from the Assumptions worksheet.
However, screenshot 4 shows the impact of where the lookup_value is less than the minimum value in the lookup_vector. In this example, our lookup_value is the operations year counter, which has a zero value during the construction phase. If we try to lookup zero in the generation per turbine input table, which has a minimum value of 1 (i.e., OY 1 is the first year of operations), LOOKUP returns an error. Therefore we will need to isolate this error and use an IF statement to return zero where this is the case, as illustrated.
Please refer to the accompanying workbook on other examples of using the simple LOOKUP function instead of VLOOKUP/HLOOKUP.
As described above, VLOOKUP and HLOOKUP functions have certain drawbacks that could lead to potential errors, especially for users unfamiliar with the model. Although the simple LOOKUP function could sometimes be used to replace VLOOKUP/HLOOKUP, it is limited to a single row or column to hold results. In some cases, using a combination of INDEX(MATCH) functions may be the only solution, as they are more robust and versatile than VLOOKUP/HLOOKUP.
The steps to solve the example using INDEX(MATCH) are:
With Excel 365, Microsoft have introduced a variety of new and improved functions including XLOOKUP. It is mostly the same as LOOKUP, however with three additional inputs: if_not_found, match_mode, search_mode.
We are able to use the if_not_found field to negate the need for an IF statement where the lookup_value is less than the minimum value in the lookup_vector of a LOOKUP function, simply by entering a zero.
The match_mode has four choices, three of which we find useful in financial modelling:
This means we can use XLOOKUP to perform the same role as INDEX(MATCH) for an exact match by using a “0” input in the match_mode. Alternatively, it will replicate the logic of LOOKUP where we use “-1”. We also have added functionality with the addition of being able to match the next largest value where no exact match can be found.
Microsoft Excel is an integral part of the business landscape and it is a critical...
This website uses cookies.
Some of these cookies are necessary, while others help us analyse our traffic, serve advertising and deliver customised experiences for you. For more information on the cookies we use, please refer to our Privacy Policy.
This website cannot function properly without these cookies.
Analytical cookies help us enhance our website by collecting information on its usage.
We use marketing cookies to increase the relevancy of our advertising campaigns.