Vlookup and Hlookup Function in Excel | computerskagyan

 VLOOKUP

VLOOKUP is a powerful function in Microsoft Excel that allows users to quickly find specific data within a range or table and retrieve a corresponding value. This function is particularly useful when working with large sets of data and can save a significant amount of time compared to manually searching for values within a dataset.

The basic syntax of the VLOOKUP function is as follows:

=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])

vlookup, hlookup, function in excel

Let's break down each of the arguments in this function:

  • lookup_value: This is the value that you want to search for within the first column of the table or range. This value can be a reference to a cell or a text string enclosed in quotation marks.
  • table_array: This is the range of cells that contains the data you want to search through. It is important to note that the lookup value must be in the leftmost column of the table or range. The table_array can be a reference to a range of cells or a named range.
  • col_index_num: This argument tells Excel which column to retrieve the value from. For example, if you are searching for a price and the table or range contains columns for product name, product ID, and price, then col_index_num should be set to 3 (since the price is in the third column).
  • [range_lookup]: This is an optional argument that tells Excel whether to look for an exact match (FALSE) or an approximate match (TRUE) for the lookup value. If this argument is omitted, Excel will assume an approximate match.
Now let's look at an example to see how the VLOOKUP function works:

Suppose you have a table of product information, including the product name, ID, and price, as shown below:

vlookup, hlookup, function in excel

You want to find the price of Widget A. You can use the VLOOKUP function to do this by entering the following formula into a cell:

=VLOOKUP(A9, A2:C5, 3, FALSE)

Here, A9 is the lookup value that we want to find in the leftmost column of the table and you can change A9 according to you. A2:C5 is the range of cells that contains the table data, and 3 is the column index number for the Price column. FALSE is used to indicate an exact match.

When you press enter, Excel will search for "Widget A" in the leftmost column of the table and return the corresponding price of $10.

It is important to note that if the lookup value is not found in the leftmost column of the table, the VLOOKUP function will return an error. Additionally, if the range_lookup argument is set to TRUE, Excel will search for an approximate match based on the nearest value in the leftmost column of the table. This can be useful in certain cases, such as when searching for a range of values (e.g. price ranges), but it can also lead to unexpected results if not used carefully.

In summary, the VLOOKUP function is a powerful tool that allows users to quickly search for and retrieve data within a table or range. By understanding the syntax and how to use the arguments correctly, you can save a significant amount of time when working with large sets of data in Excel.

HLOOKUP

HLOOKUP is a function in Microsoft Excel that works similarly to the VLOOKUP function, but searches for a value in the first row of a table or range and returns a corresponding value from a specified row. This function is useful when working with tables where the headers are in the first row rather than the first column.

The basic syntax of the HLOOKUP function is as follows:

=HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])

vlookup, hlookup, function in excel


Let's break down each of the arguments in this function:

  • lookup_value: This is the value that you want to search for within the first row of the table or range. This value can be a reference to a cell or a text string enclosed in quotation marks.
  • table_array: This is the range of cells that contains the data you want to search through. It is important to note that the lookup value must be in the first row of the table or range. The table_array can be a reference to a range of cells or a named range.
  • row_index_num: This argument tells Excel which row to retrieve the value from. For example, if you are searching for the price of a product with the name "Widget C" and the table or range contains rows for product name, product ID, and price, then row_index_num should be set to 3 (since the price is in the third row).
  • [range_lookup]: This is an optional argument that tells Excel whether to look for an exact match (FALSE) or an approximate match (TRUE) for the lookup value. If this argument is omitted, Excel will assume an approximate match.
Now let's look at an example to see how the HLOOKUP function works:

Suppose you have a table of product information, including the product name, ID, and price, as shown below:

vlookup, hlookup, function in excel


You want to find the price of Widget C. You can use the HLOOKUP function to do this by entering the following formula into a cell:

=HLOOKUP("Widget C", A1:E2, 2, FALSE)

Here, "Widget C" is the lookup value that we want to find in the first row of the table. A1:E2 is the range of cells that contains the table data, and 2 is the row index number for the Price row. FALSE is used to indicate an exact match.

When you press enter, Excel will search for "Widget C" in the first row of the table and return the corresponding price of $20.

It is important to note that if the lookup value is not found in the first row of the table, the HLOOKUP function will return an error. Additionally, if the range_lookup argument is set to TRUE, Excel will search for an approximate match based on the nearest value in the first row of the table. This can be useful in certain cases, such as when searching for a range of values (e.g. price ranges), but it can also lead to unexpected results if not used carefully.

In summary, the HLOOKUP function is a useful tool for searching for data within the first row of a table or range in Excel. By understanding the syntax and how to use the arguments correctly, you can quickly retrieve the data you need without having to manually search through large sets of data.

Comments