Lookup Functions in Excel: In today’s blog let’s talk about Lookup Functions in Excel.
VLOOKUP
If you need to find something adjacent to an element in a range by row then use VLOOKUP. For example, look up the price of an automotive part by the part number, or find an employee name based on their employee ID.
Syntax
=VLOOKUP (lookup_value, table_array, column_index, [approx. or exact match])
Arguments:
- Lookup_value: What you want to look up (value or cell no.)
- Table_array: Where you want to look for it (table range)
- Column_index: The column number in the range containing the value to return
- [approx. or exact match]: This field is optional. It returns an Approximate or Exact match – indicated as 1/TRUE, or 0/FALSE). If this argument is left blank. VLOOKUP will perform an approximate match.
Let us look at a quick example demonstrating the use of the VLOOKUP function.
Suppose we have the following data,
Now we want a field which will give the price of the fruit, if we enter the name of the fruit in the E10 cell.
We will use the below formula:
=VLOOKUP(E10, A10:B14, 2,)
Implementing the above VLOOKUP we get,
Let’s try something which isn’t present in table:
It throws an error #NA.
HLOOKUP function
H in the HLOOKUP stands for Horizontal. 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.
Use HLOOKUP when your comparison values are located in a row across the top of a table of data, and you want to look down a specified number of rows.
Use VLOOKUP when your comparison values are located in a column to the left of the data you want to find.
Syntax
=HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])
Arguments:
- Lookup_value It is a Required argument. The value to be found in the first row of the table. Lookup_value can be a value, a reference, or a text string.
- Table_array It is a Required argument. A table of information in which data is looked up. Use a reference to a range or a range name.
- Row_index_num [Required] The row number in table_array from which the matching value will be returned. A row_index_num of 1 returns the first row value in table_array.
- Range_lookup [Optional] If TRUE or omitted, an approximate match is returned. In other words, if an exact match is not found, the next largest value that is less than lookup_value is returned. If FALSE, HLOOKUP will find an exact match. If one is not found, the error value #N/A is returned.
Let us look at a quick example demonstrating the use of VLOOKUP function.
Suppose we have the following data:
And we want to extract the price of the given Vegetable for a given month.
To implement this, we are using the below formula:
=HLOOKUP(D10,A2:I8,5,FALSE)
Here by using the above formula we have extracted the price of Garlic for the month of August.
Points to remember:
- If HLOOKUP can’t find lookup_value, and range_lookup is TRUE, it uses the largest value that is less than lookup_value.
- In case of lookup_value smaller than the smallest value in the first row of table_array, HLOOKUP returns the #N/A error value.
- If range_lookup is FALSE and lookup_value is text, you can use the wildcard characters, question mark (?) and asterisk (*), in lookup_value. A question mark matches any single character; an asterisk matches any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) before the character.
Hope you have learned something from this post. If You find any errors, you can read our blog on how to Fix Errors using VLOOKUP in Excel
Keep Learning!