Imagine you work in a school in Ibadan with records for 1,000 students. Each student has a name, registration number, class, and examination score.
Your teacher asks you to find the examination score of a student named Ade. Searching through all 1,000 records manually could take a long time.
Fortunately, Microsoft Excel has lookup and reference functions that help you find specific information quickly. Instead of checking every row yourself, you can enter a formula and allow Excel to search for the information.
By the end of this module, you should be able to:
Lookup functions help you search for information in a spreadsheet and return related information from another cell.
For example, if you know a student's registration number, you can use a lookup function to find the student's name, class, or examination score.
These functions are especially useful when working with large datasets containing hundreds or thousands of records.
VLOOKUP means Vertical Lookup. It searches for information in the first column of a table and returns a related value from another column in the same row.
Think of it as asking Excel to find a student's registration number and return the student's examination score.
=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
Here is what each part means:
A school in Lagos has the following examination records:
| Student ID | Student Name | Class | Score |
|---|---|---|---|
| ST001 | Ade | JSS 1 | 75 |
| ST002 | Chika | JSS 2 | 90 |
| ST003 | Tunde | JSS 1 | 65 |
| ST004 | Fatima | JSS 3 | 85 |
Assume the table is stored in cells A2:D5. You want to find the score of student ST002.
Enter this formula:
=VLOOKUP("ST002",A2:D5,4,FALSE)
Result: 90
Excel searches for ST002 in the first column, finds the student's row, and returns the value in the fourth column.
In the VLOOKUP formula, the column number is counted from the beginning of the selected table range, not from the entire worksheet.
HLOOKUP means Horizontal Lookup. It searches for information across the first row of a table and returns a related value from another row.
While VLOOKUP searches vertically down a column, HLOOKUP searches horizontally across a row.
=HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])
Imagine a supermarket in Ibadan has arranged its monthly sales records horizontally.
| Information | January | February | March | April |
|---|---|---|---|---|
| Sales (โฆ) | 50000 | 65000 | 80000 | 75000 |
| Expenses (โฆ) | 20000 | 25000 | 30000 | 28000 |
Assume the table is stored in A1:E3. To find the sales amount for March, enter:
=HLOOKUP("March",A1:E3,2,FALSE)
Result: โฆ80,000
Excel searches for March in the first row and returns the value from the second row.
XLOOKUP is a modern lookup function that makes searching for information easier and more flexible.
Unlike VLOOKUP, XLOOKUP can search in one range and return information from another range, even when the result column is to the left of the search column.
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found])
Here is what the arguments mean:
Using the student records from the earlier example, assume student IDs are in A2:A5 and names are in B2:B5.
To find the name of student ST003, enter:
=XLOOKUP("ST003",A2:A5,B2:B5,"Student Not Found")
Result: Tunde
If ST003 does not exist in the selected range, Excel displays Student Not Found.
Note: XLOOKUP is available in newer versions of Excel, including Microsoft 365 and Excel 2021 or later. Older versions may not support it.
INDEX returns a value from a specific position in a selected range.
Imagine you have a list of student names and want to retrieve the name in the third position. INDEX can help you do this.
=INDEX(array, row_num, [column_num])
Assume cells A2:A5 contain these names:
Enter:
=INDEX(A2:A5,3)
Result: Tunde
Excel returns the third value in the selected range.
MATCH searches for a value in a range and returns its position.
It does not return the actual information in the cell. Instead, it tells you where the matching value is located.
=MATCH(lookup_value, lookup_array, [match_type])
For an exact match, use 0 as the match type.
Assume the names Ade, Chika, Tunde, and Fatima are stored in cells A2:A5.
To find the position of Tunde, enter:
=MATCH("Tunde",A2:A5,0)
Result: 3
Tunde is the third item in the selected range.
INDEX and MATCH can work together to find information in a spreadsheet.
MATCH finds the position of the information you are searching for, while INDEX returns the related value from another range.
Assume student IDs are stored in A2:A5 and examination scores are stored in D2:D5.
To find the examination score of ST003, enter:
=INDEX(D2:D5,MATCH("ST003",A2:A5,0))
Result: 65
MATCH first finds the position of ST003. INDEX then uses that position to return the score from the corresponding location in the score range.
| Function | How It Searches | Best Use |
|---|---|---|
| VLOOKUP | Searches vertically down the first column. | Finding information in vertically arranged tables. |
| HLOOKUP | Searches horizontally across the first row. | Finding information in horizontally arranged tables. |
| XLOOKUP | Searches a selected range and returns a value from another range. | Flexible searches in modern Excel versions. |
| INDEX | Returns a value from a specified position. | Retrieving information from a selected range. |
| MATCH | Finds the position of a matching value. | Locating the position of an item in a range. |
Also check for extra spaces and inconsistent data formats. For example, a student ID stored as text may not match the same-looking value stored as a number.
A computer training centre in Nigeria has created a spreadsheet containing information about its students.
| Student ID | Name | Course | Score |
|---|---|---|---|
| CRM001 | Ade | Excel | 85 |
| CRM002 | Mary | Power BI | 90 |
| CRM003 | John | Data Analysis | 75 |
| CRM004 | Grace | Cybersecurity | 95 |
| CRM005 | Peter | Excel | 80 |
In this module, you learned how to find and retrieve information from Excel spreadsheets using lookup and reference functions.
These functions are useful when working with school databases, employee records, customer information, product lists, and business reports.
In Module 8, you will learn about Statistical and Conditional Calculation Functions in Excel. You will discover how to calculate averages, count records based on conditions, and analyse data using functions such as AVERAGEIF, AVERAGEIFS, SUMIF, and SUMIFS.