The HLOOKUP Function looks up a value you designate in the first row of a worksheet area and returns a value from the column it finds the lookup value in. Used to merge tables, construct dashboards and perform various data processing tasks.
The HLOOKUP function is a computer program that you run from a worksheet cell formula. It looks up a value you designate in the first row of a worksheet area (called a range) and returns a value from the column it finds the lookup value in. You run the HLOOKUP worksheet function by typing its name in a formula then followed by the information it is suppose to use. The HLOOKUP worksheet function is used in applications when you have to look up prices, name information, scientific data anything that is contained in a table. It can also be used to merge two tables together transferring information from one to the other. The H in HLOOKUP stands for horizontal. There is also another function called VLOOKUP that looks along the first column of a table. Use VLOOKUP when your comparison values are located in the first column of the data that you want to find. Note that this function also has the capability to search for parts of text within other text when evaluating its lookup value.
Whenever you type a formula in a worksheet cell, this is called syntax or grammar. The general HLOOKUP function syntax has a format like this when you type it in a worksheet cell:
= HLOOKUP( lookup_value, table_array, row_index_num, [range_lookup] )
Where lookup_value, table_array, row_index_num, [range_lookup] are called the function argument list. Remember, you are running a computer program at this point so the program needs information to operate and that is why there is an argument list. When you see an argument list and you see square brackets [ ] around the argument name, this means the argument is optional and you do not have to include it when typing unless you need it. So for the syntax above, you need to include 3 arguments for the HLOOKUP worksheet function when typing it in a worksheet cell formula in order for it to calculate correctly. What argument values can be used are discussed below. Remember functions expect certain things in their argument lists, if you do not put the correct information in the list they will generate an error when run.
Since the HLOOKUP function is a computer program, it runs when you press Enter to enter the formula that contains it. If any of the arguments are wrong, the function will return an error.
When typing the HLOOKUP function in a worksheet cell formula, you need to replace the argument list with arguments separating each one with a comma (,). Some typical arguments you can use are:
|= HLOOKUP( "Widgets", A1:D5, 2, FALSE )||Find Widgets in the A1:D1 range then return information from row 2 in the column that Widgets was found in|
|= HLOOKUP( "*ST*", G1:J5, 4, FALSE )||Find the piece of text ST inside the cell value text in the G1:J1 range then return information from row 4 in the column that ST was found in|
|= HLOOKUP( "*" & B1 & "*", G1:J5, 2, FALSE )||Find the piece of text from the B1 cell value inside the text in the G1:J1 range then return information from row 2 in the column that the text was found in|
|= HLOOKUP( 16, B1:D5, 5, FALSE )||Find number 16 in the B1:D1 range then return information from row 5 in the column that 16 was found in|
|= HLOOKUP( B1, Prices, 3, FALSE )||Find the B1 cell value in range name Prices first row then return information from row 3 in the column that the B1 cell value was found in *|
* This function is used a great deal in building adaptive formulas that figure out ranges, start and stop of data.... It is also heavily used in dashboard design tying numeric ActiveX control outputs into formulas that seek out data in tables.
The worksheet seen below contains some typical worksheet formulas that run the VLOOKUP worksheet function. Pay close attention to the argument list and the syntax used to write the formula.
|1||Searching by Names|
|8||Look up Cost header and return info about Widget1 cost. Formula below|
|9||Widget1||$1.25||= HLOOKUP( "Cost", A3:B6, 2, FALSE )|
|11||Item||Cost||Allow user to search for header Cost and return info about Widget1 cost. Formula below|
|12||Widget1||$1.25||= HLOOKUP( B11, A3:B6, 2, FALSE )|
|14||Item||Cost||Allow user to search for Cost header, use range name Widgets in place of A3:B6 much easier, can be on different sheet. Formula below|
|15||Widget1||$1.25||= HLOOKUP( B14, Widgets, 2, FALSE )|