Module 8 MS Excel Functions
Module 8 MS Excel Functions
Tips:
▪ The secret to VLOOKUP is to organize your data so that the value you look up (Fruit) is to the left
of the return value (Amount) you want to find.
▪ If you're a Microsoft Copilot subscriber Copilot can make it even easier to insert and use VLookup
or XLookup functions. See Copilot makes lookups in Excel easy.
=VLOOKUP(lookup value, range containing the lookup value, the column number in the range
containing the return value, Approximate match (TRUE) or Exact match (FALSE)).
Examples
Example 2
Example 3
Example 4
Example 5
2. HLOOK UP
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.
The H in HLOOKUP stands for "Horizontal."
Formula
=HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])
=HLOOKUP(value to look up, table area, row number)
▪ If HLOOKUP can't find lookup_value, and range_lookup is TRUE, it uses the largest value that is
less than lookup_value.
▪ If lookup_value is 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.
Example
Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For
formulas to show results, select them, press F2, and then press Enter. If you need to, you can
adjust the column widths to see all the data.
HLOOK UP Example.
Let us consider the example below. The marks of four subjects for five students are as follows:
Now, if our objective is to fetch the marks of student D in Management, we can use HLOOKUP as
follows:
The next step would be to give the table array. Table array is nothing but rows of data in which the
lookup value would be searched. Table array can be a regular range or a named range, or even an
Excel table. Here, we will give row A1:F5 as the reference.
Next, we would define ‘row_index_num,’ which is the row number in the table_array from where the
value would be returned. In this case, it would be 4, as we are fetching the value from the fourth row of
the given table.
Here, HLOOKUP is searching for a particular value in the table and returning an exact or approximate
value.
Important points to keep in mind about HLOOKUP
1. It is a case-insensitive lookup. It will consider, for example, “TIM” and “tim” as the same.
2. The ‘Lookup_value’ should be the topmost row of the ‘table_array’ when we are using
HLOOKUP. If we need to look somewhere else, then we must use another Excel formula.
3. HLOOKUP supports wildcard characters such as ‘*’ or ‘?’ in the ‘lookup_value’ argument (only if
‘lookup_value’ is text).
Let’s understand this using an example.
Suppose we are given names of student and marks below:
If we need to use the Horizontal Lookup formula to find the Math marks of a student whose name starts
with a ‘D,’ the formula will be:
6. Remember HLOOKUP function in Excel can return only one value. This would be the first value n
that matches the lookup value. What if there are a few identical records in the table? In that scenario, it
is advisable to remove them or create a Pivot table and group them. The array formula can then be
used on the Pivot table to extract all duplicate values that are present in the lookup range.
To learn more, launch our free Excel crash course now!
HLOOKUP from another workbook or worksheet
It means giving an external reference to our HLOOKUP formula. Using the same table, the marks of
students in subject Business Finance are given in sheet 2 as follows:
As shown in the table above, if I need to extract the marks of Cathy in all subjects, then I need to use
the following formula:
If you wish to get an array, you need to select the number of cells that are equal to the number of rows
that you want HLOOKUP to return.
After typing FALSE, we need to press Ctrl + Shift + Enter instead of the Enter key. Why do we need to
do so?
Ctrl + Shift + Enter will enclose the HLOOKUP formula in curly brackets. As shown below, all cells will
give the results in one go. We will be saved from having to type the formula in each cell.
3. XLOOK UP
Use the XLOOKUP function to find things in a table or range by row. For example, look up the price
of an automotive part by the part number, or find an employee name based on their employee ID.
With XLOOKUP, you can look in one column for a search term and return a result from the same
row in another column, regardless of which side the return column is on.
Note: XLOOKUP is not available in Excel 2016 and Excel 2019. However, you may come across a
situation of using a workbook in Excel 2016 or Excel 2019 with the XLOOKUP function in it, if it was
created by someone else using a newer version of Excel.
XLOOKUP function
Applies To
Use the XLOOKUP function to find things in a table or range by row. For example, look up the price
of an automotive part by the part number, or find an employee name based on their employee ID.
With XLOOKUP, you can look in one column for a search term and return a result from the same
row in another column, regardless of which side the return column is on.
Note: XLOOKUP is not available in Excel 2016 and Excel 2019. However, you may come across a
situation of using a workbook in Excel 2016 or Excel 2019 with the XLOOKUP function in it, if it was
created by someone else using a newer version of Excel.
Pause
Current Time 0:28
/
Duration 0:44
Loaded: 100.00%
Download
Captions
Audio Track
More options
Mute
Fullscreen
Play Video
Syntax
The XLOOKUP function searches a range or an array, and then returns the item corresponding to
the first match it finds. If no match exists, then XLOOKUP can return the closest (approximate)
match.
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found],
[match_mode], [search_mode])
Argument Description
[if_not_found] Where a valid match is not found, return the [if_not_found] text you
supply.
Optional
If a valid match is not found, and [if_not_found] is missing, #N/A is
returned.
Examples
Example 1 uses XLOOKUP to look up a country name in a range, and then return its telephone
country code. It includes the lookup_value (cell F2), lookup_array (range B2:B11),
and return_array (range D2:D11) arguments. It doesn't include the match_mode argument, as
XLOOKUP produces an exact match by default.
Note: XLOOKUP uses a lookup array and a return array, whereas VLOOKUP uses a single table
array followed by a column index number. The equivalent VLOOKUP formula in this case would
be: =VLOOKUP(F2,B2:D11,3,FALSE)
Example 4 looks in column C for the personal income entered in cell E2, and finds a matching
tax rate in column B. It sets the if_not_found argument to return 0 (zero) if nothing is found.
The match_mode argument is set to 1, which means the function will look for an exact match, and
if it can't find one, it returns the next larger item. Finally, the search_mode argument is set to 1,
which means the function will search from the first item to the last.
Note: XARRAY's lookup_array column is to the right of the return_array column, whereas
VLOOKUP can only look from left-to-right.
———————————————————————————
Example 5 uses a nested XLOOKUP function to perform both a vertical and horizontal match. It
first looks for Gross Profit in column B, then looks for Qtr1 in the top row of the table (range
C5:F5), and finally returns the value at the intersection of the two. This is similar to using
the INDEX and MATCH functions together.
Tip: You can also use XLOOKUP to replace the HLOOKUP function.
Example 6 uses the SUM function, and two nested XLOOKUP functions, to sum all the values
between two ranges. In this case, we want to sum the values for grapes, bananas, and include
pears, which are between the two.
References
https://support.microsoft.com/en-us/office/vlookup-function-0bbc8083-26fe-4963-8ab8-
93a18ad188a1
https://support.microsoft.com/en-us/office/hlookup-function-a3034eec-b719-4ba3-bb65-
e1ad662ed95f
https://support.microsoft.com/en-us/office/xlookup-function-b7fd680e-6d10-43e6-84f9-
88eae8bf5929
https://corporatefinanceinstitute.com/resources/excel/hlookup-function/