hlookup formula in excel
HLOOKUP stands for Horizontal Lookup and is a useful function in Excel for retrieving data from a table by searching a row for the matching data and returning the value from the corresponding column. It is often used in conjunction with other excel lookup functions to perform efficient data retrieval across tables. There is huge difference between VLOOKUP and HLOOKUP formula in excel, while in VLOOKUP we retrieve lookup value vertically though in HLOOKUP we retrieve values horizontally.
Syntax for HLOOKUP:
=HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])
lookup_value: The value to search for in the first row of the table.
table_array: The range of cells that contains the data. The first row of this range is searched for the lookup value.
row_index_num: The row number in the table_array from which to retrieve the value.
range_lookup: Optional. If TRUE (default), HLOOKUP will find an approximate match. If FALSE, it will find an exact match.
Step-by-Step Process for Using HLOOKUP:
- Identify the Lookup Value: Determine the value you want to use as the basis for searching the table. This value is typically located in a separate column from the table you’re searching.
- Define the Table Array: Specify the range of cells that represents the table you want to search. This includes all the columns in the table, from the first to the last.
- Specify the Row Index Number: Indicate the row number within the table array where the matching value is expected to be found. This number corresponds to the position of the lookup value in the corresponding column.
- Set Range Lookup (Optional): Choose whether to perform an exact match (FALSE) or an approximate match (TRUE). If set to TRUE, HLOOKUP will return the nearest match if the exact value is not found.
- Construct the HLOOKUP Formula: Combine the identified elements into the HLOOKUP formula as mentioned in above syntax
Example of HLOOKUP formula in excel
In the below example we have data for sales for few states of US month on month. States name are in column and months name is in rows. We wanted to retrieve sales number for Delaware for July 22. So we will use HLOOKUP function where in we will use Delaware as lookup value and used A1:S24 as table_array while June 22 is the 7th row from A1 so we put 7 as row_index_num and finally 0 for exact match.
Example of HLOOKUP formula in excel with MATCH function
In the bellow example we used excel MATCH function to make the changes dynamic. By using MATCH function of excel we made row_index_num dynamic. So now we can change month number and values will retrieve accordingly.
- Make sure your data is sorted correctly if you are using approximate matching (range_lookup = TRUE).
- If the lookup value is not found, HLOOKUP formula in excel returns an error. You can use functions like IFERROR to handle this.
Remember to adapt the formula based on your specific data and requirements. The key is to understand the structure of your data and the arguments of the HLOOKUP function. HLOOKUP is a versatile tool for retrieving data from tables in Excel. By understanding its components and following the step-by-step process, you can effectively utilize HLOOKUP to perform data lookups and enhance your spreadsheet analysis.
You can read on HLOOKUP formula from this link.
You can also download the working file from below.