HLOOKUP function is a powerful tool that allows you to search for a specific value in a table or range of cells and return a corresponding value from a row in the same table. It’s especially useful when you have a large dataset and need to quickly find specific information.
One of the great things about HLOOKUP is that it’s easy to use and understand. Simply specify the value you want to search for, the range of cells where you want to search, and the column index number of the value you want to return. You can also specify whether you want an exact or approximate match, as well as which row you want to start the search from. With HLOOKUP, you’ll be able to efficiently locate and retrieve information from your Google Sheets documents in no time!
Table of Contents
Definition of HLOOKUP Function
HLOOKUP (Horizontal Lookup) is a function in Google Sheets that allows you to search for a specific value in a table or range of cells and return a corresponding value from a row in the same table. It has the following syntax: HLOOKUP(search_key, range, index, [is_sorted]) – where the “search_key” is the value you want to search for, the “range” is the set of cells where you want to search, the “index” is the column index number of the value you want to return, and the “is_sorted” is an optional parameter that specifies whether the range is sorted in ascending order (set to TRUE or 1) or not (set to FALSE or 0). HLOOKUP is a useful function for quickly finding specific information in a large dataset and can be used in a variety of applications.
Syntax of HLOOKUP Function
The syntax of the HLOOKUP function in Google Sheets is as follows:
=HLOOKUP(search_key, range, index, [is_sorted])
Here’s what each of these parameters means:
- search_key: This is the value you want to search for in the specified range.
- range: This is the set of cells where you want to search for the search key. It should include at least two rows, with the first row being used as the lookup row.
- index: This is the column index number of the value you want to return. For example, if you want to return a value from the third column in the range, you would specify 3 as the index.
- is_sorted: This is an optional parameter that specifies whether the range is sorted in ascending order (set to TRUE or 1) or not (set to FALSE or 0). If the range is not sorted, HLOOKUP will use an approximate match to find the search key. If the range is sorted, HLOOKUP will use an exact match.
Here’s an example of how you might use the HLOOKUP function in a Google Sheets formula:
=HLOOKUP(A1, B1:D10, 2, TRUE)
This formula would search for the value in cell A1 in the range B1:D10, and return the value in the second column of the row where the search key was found. The range is assumed to be sorted in ascending order, so an exact match is used.
Examples of HLOOKUP Function
- Searching for a specific value in a table and returning a corresponding value:
Suppose you have a table of data that contains employee names, IDs, and departments, and you want to search for a specific employee name and return their ID. You could use the HLOOKUP function to do this as follows:=HLOOKUP("John Smith", A1:C10, 2, TRUE)
This formula would search for the value “John Smith” in the first column of the range A1:C10, and return the value in the second column of the row where the search key was found.
- Searching for a value and returning a corresponding value from a different sheet:
You can also use the HLOOKUP function to search for a value in a different sheet and return a corresponding value from that sheet. For example, suppose you have a sheet called “Sheet1” that contains a table of data, and you want to search for a specific value in that table and return a corresponding value from a different sheet called “Sheet2”. You could use the HLOOKUP function as follows:=HLOOKUP(A1, Sheet1!A1:C10, 3, TRUE, Sheet2!A1:D10)
This formula would search for the value in cell A1 in the range A1:C10 on Sheet1, and return the value in the third column of the row where the search key was found, using the range A1:D10 on Sheet2 as the lookup range.
- Searching for an approximate match:
By default, the HLOOKUP function uses an exact match to find the search key. However, you can use the is_sorted parameter to specify that you want an approximate match instead. For example, suppose you have a table of data that contains employee names and salaries, and you want to find the salary of the employee whose name is closest to the value you specify. You could use the HLOOKUP function as follows:=HLOOKUP("John Smith", A1:B10, 2, FALSE)
This formula would search for an approximate match for the value “John Smith” in the first column of the range A1:B10, and return the value in the second column of the row where the closest match was found.
Use Case of HLOOKUP Function
- Searching for a specific product in a product catalog and returning the price:
Suppose you have a product catalog in a Google Sheet that contains the product names, IDs, and prices, and you want to search for a specific product and return the price. You could use the HLOOKUP function to do this as follows:=HLOOKUP("Smartphone", A1:C10, 3, TRUE)
This formula would search for the value “Smartphone” in the first column of the range A1:C10, and return the value in the third column of the row where the search key was found.
- Searching for a student’s name in a gradebook and returning their grade:
Suppose you have a gradebook in a Google Sheet that contains the names of students, their IDs, and their grades, and you want to search for a specific student’s name and return their grade. You could use the HLOOKUP function to do this as follows:=HLOOKUP("Mary Jones", A1:C10, 3, TRUE)
This formula would search for the value “Mary Jones” in the first column of the range A1:C10, and return the value in the third column of the row where the search key was found.
- Searching for a specific country in a table of data and returning the population:
Suppose you have a table of data in a Google Sheet that contains the names of countries, their populations, and their GDPs, and you want to search for a specific country and return its population. You could use the HLOOKUP function to do this as follows:=HLOOKUP("United States", A1:C10, 2, TRUE)
This formula would search for the value “United States” in the first column of the range A1:C10, and return the value in the second column of the row where the search key was found.
Limitations of HLOOKUP Function
There are a few limitations to consider when using the HLOOKUP function in Google Sheets:
- HLOOKUP can only search for values horizontally, not vertically. If you want to search for a value in a column and return a corresponding value from a row, you should use the VLOOKUP function instead.
- HLOOKUP can only return values from the same row as the search key, not from a different row. If you want to return a value from a different row, you can use the INDEX and MATCH functions together.
- HLOOKUP can only return a value from the same table or range as the search key. If you want to return a value from a different table or range, you can use the INDEX and MATCH functions together.
- HLOOKUP can only return a single value, not a range of values. If you want to return a range of values, you can use the INDEX and MATCH functions together.
- HLOOKUP can only return a value from the same sheet as the search key. If you want to return a value from a different sheet, you need to specify the sheet name in the range parameter.
- HLOOKUP is case-insensitive, meaning it will treat “apple” and “Apple” as the same value. If you want to perform a case-sensitive search, you can use the INDEX and MATCH functions together.
Commonly Used Functions Along With HLOOKUP
Here are some commonly used functions that can be used in combination with the HLOOKUP function in Google Sheets:
- IFERROR: This function allows you to specify a value to return if an error occurs in a formula. For example, you can use IFERROR to return a default value if HLOOKUP can’t find the search key.
=IFERROR(HLOOKUP("John Smith", A1:C10, 2, TRUE), "Not Found")
- INDEX: This function allows you to return a value from a specific cell in a range or array. For example, you can use INDEX to return a value from a different row or column than the one HLOOKUP returns.
=INDEX(A1:C10, HLOOKUP("John Smith", A1:C10, 1, TRUE), 3)
- MATCH: This function allows you to search for a specific value in a range or array and return its position. For example, you can use MATCH in combination with HLOOKUP to return a value from a different row or column than the one HLOOKUP returns.
=HLOOKUP("John Smith", A1:C10, MATCH("ID", A1:C1, 0), TRUE)
- SUM: This function allows you to add up the values in a range or array. For example, you can use SUM to total the values in the same row as the search key returned by HLOOKUP.
=SUM(HLOOKUP("John Smith", A1:C10, 1, TRUE):HLOOKUP("John Smith", A1:C10, 3, TRUE))
- AVERAGE: This function allows you to calculate the average of the values in a range or array. For example, you can use AVERAGE to calculate the average of the values in the same row as the search key returned by HLOOKUP.
=AVERAGE(HLOOKUP("John Smith", A1:C10, 1, TRUE):HLOOKUP("John Smith", A1:C10, 3, TRUE))
- MIN: This function allows you to find the minimum value in a range or array. For example, you can use MIN to find the minimum value in the same row as the search key returned by HLOOKUP.
=MIN(HLOOKUP("John Smith", A1:C10, 1, TRUE):HLOOKUP("John Smith", A1:C10, 3, TRUE))
- MAX: This function allows you to find the maximum value in a range or array. For example, you can use MAX to find the maximum value in the same row as the search key returned by HLOOKUP.
=MAX(HLOOKUP("John Smith", A1:C10, 1, TRUE):HLOOKUP("John Smith", A1:C10, 3, TRUE))
Summary
The HLOOKUP function in Google Sheets is a powerful tool for searching for a specific value in a table or range of cells and returning a corresponding value from a row in the same table. It’s easy to use and understand, and can be a great time-saver when you have a large dataset and need to quickly find specific information.
To use HLOOKUP, simply specify the value you want to search for, the range of cells where you want to search, and the column index number of the value you want to return. You can also specify whether you want an exact or approximate match, as well as which row you want to start the search from.
HLOOKUP has a number of useful applications, including searching for a specific product in a product catalog and returning the price, searching for a student’s name in a gradebook and returning their grade, and searching for a specific country in a table of data and returning the population.
We encourage you to try using the HLOOKUP function in your own Google Sheets documents and see how it can make your work easier and more efficient. With a little practice, you’ll be able to efficiently locate and retrieve information from your sheets in no time!
Video: HLOOKUP Function
In this video, you will see how to use HLOOKUP function. We suggest you to watch the video to understand the usage of HLOOKUP formula.