Hand Out LOOKUP FUNCTIONS
Hand Out LOOKUP FUNCTIONS
VLOOKUP
Purpose: Searches for a value in the first column of a table and returns a
value in the same row from a specified column.
Limitations:
● Can only search in the first column of the table.
● Not suitable for dynamic column reference.
● Inefficient with large datasets.
● for effective use.
HLOOKUP Function
The HLOOKUP function is designed to search for a value in the top row of a
table or range and returns a value in the same column from a specified row.
What is HLOOKUP?
HLOOKUP stands for Horizontal Lookup.
● Searches for a value in the top row of a table or range.
● Returns a value in the same column from a row you specify.
● Useful for finding items in a table or a range by row.
Syntax
1
HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])
lookup_value: The value to search for in the first row of the table_array.
table_array: The range of cells that contains the data. You can use a reference
to a range or a range name.
row_index_num: The row number in the table_array from which to retrieve
the value. Row 1 is the first row in table_array.
[range_lookup]: Optional. A logical value that specifies whether you want
HLOOKUP to find an exact match or an approximate match:
TRUE (or omitted) - returns an approximate match. Assumes the first row in
the table_array is sorted in ascending order.
FALSE - returns an exact match or #N/A if no match is found.
Examples
Exact Match
Approximate Match
=HLOOKUP(100, A1:D2, 2)
Assuming the first row of A1:D1 contains sorted numbers, this finds the largest
value less than or equal to 100 in the first row and returns the value from the
second row in the corresponding column. It allows for an approximate match
because the fourth argument is omitted (or TRUE).
Tips
● If HLOOKUP cannot find the lookup value, and [range_lookup] is TRUE,
it returns the largest value that is less than or equal to the lookup value.
● 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.
2
● For vertical lookup, where comparison values are in a column to the left
of the data you want to find, use VLOOKUP instead.
XLOOKUP Function
XLOOKUP is a powerful function in Excel that replaces older functions like
VLOOKUP and HLOOKUP. It allows you to search a range or array, find the
right value, and return a corresponding value from a different range or array.
Syntax of XLOOKUP
XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found],
[match_mode], [search_mode])
Example Uses
1. Basic XLOOKUP:
● Find the name of a student based on their ID.
3
2. XLOOKUP with Not Found Message:
● Lookup with a custom message if the value is not found.
Finds the first course name starting with "Bio" and returns the
corresponding instructor's name.
4. Two-way Lookup:
● Find a specific grade for a student in a course.
Nested XLOOKUP: first, it finds the row with the student's grade, then finds
the grade for "ENG304".
4
Tips
● XLOOKUP is only available in Excel for Office 365 and Excel 2019.
● It's more robust and less prone to errors compared to
VLOOKUP/HLOOKUP.
● You can use XLOOKUP for both vertical and horizontal lookups.
Common Errors
● #N/A: Indicates that the function did not find the lookup_value.
● #REF!: Occurs if row_index_num is greater than the number of rows in
table_array.
● #VALUE!: If row_index_num is less than 1.
VLOOKUP
1. Employee Data Management: Use VLOOKUP to retrieve employee information
such as salary, department, or contact details based on their employee ID or name
from a separate employee database table.
2. Sales Analysis: Calculate sales commissions by looking up commission rates from a
table based on sales amounts.
3. Inventory Management: Retrieve product details such as price, quantity, or
description from an inventory table using product codes.
4. Gradebook Calculation: Assign letter grades to student scores by looking up grade
boundaries from a grading scale table based on their numeric score.
5. Customer Relationship Management (CRM): Retrieve customer information like
contact details, purchase history, or account status from a CRM database table
based on customer IDs.
5
HLOOKUP
1. Budget Planning: Retrieve budget figures for various expense categories (e.g.,
marketing, operations, salaries) from a budget table based on month names or
quarter names.
2. Project Management: Retrieve project status updates (e.g., completion
percentage, milestones achieved) from a project tracking table based on project IDs
or names.
3. Forecasting: Extract historical sales data for different products or regions from a
sales data table based on time periods (e.g., months, quarters).
4. Survey Analysis: Retrieve survey responses (e.g., ratings, comments) for specific
questions from a survey results table based on question IDs or topics.
5. Employee Shift Scheduling: Retrieve employee work schedules (e.g., shift times,
days off) from a scheduling table based on employee IDs or names.
XLOOKUP
1. Advanced Data Lookup: Use XLOOKUP to perform exact or approximate matches
with greater flexibility than VLOOKUP or HLOOKUP, including wildcard matches.
2. Data Reconciliation: Compare two datasets and retrieve corresponding values
from one dataset based on matches found in the other dataset.
3. Data Validation: Validate input data against a reference dataset and return error
messages or warnings for unmatched or invalid entries.
4. Dynamic Data Analysis: Create dynamic dashboards or reports that update
automatically based on user-selected criteria or filters using XLOOKUP to retrieve
relevant data.
5. Large Dataset Lookup: Handle large datasets more efficiently with XLOOKUP's
ability to perform searches faster than traditional lookup functions, especially in
scenarios involving millions of records.