Excel Lookup & Logical Functions: VLOOKUP, HLOOKUP, XLOOKUP, IF, AND, OR
1. VLOOKUP (Vertical Lookup)
----------------------------
Purpose:
Searches vertically in the first column of a table to find a value and returns data from another column
in the same row.
Syntax:
VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
Example Table:
| Product ID | Product Name | Price |
|------------|--------------|-------|
| 101 | Pen | 10 |
| 102 | Pencil |5 |
| 103 | Eraser |3 |
Task: Find the name of the product with Product ID 102.
Formula:
=VLOOKUP(102, A2:C4, 2, FALSE)
Result: "Pencil"
2. HLOOKUP (Horizontal Lookup)
------------------------------
Purpose:
Searches horizontally in the first row of a table and returns data from a specified row in the same
column.
Syntax:
HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])
Example Table:
| |A |B |C |
|-----------|----------|---------|---------|
| Item | Pen | Pencil | Eraser |
| Price | 10 |5 |3 |
| Stock | 50 | 100 | 80 |
Task: Find the price of the Pencil.
Formula:
=HLOOKUP("Pencil", A1:C3, 2, FALSE)
Result: 5
3. XLOOKUP (Excel 365 and 2019+)
-------------------------------
Purpose:
Replaces VLOOKUP and HLOOKUP. Looks both vertically and horizontally. More flexible and
powerful.
Syntax:
XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
Vertical Lookup Example:
| A (Product ID) | B (Product Name) | C (Price) |
|----------------|------------------|-----------|
| 101 | Pen | 10 |
| 102 | Pencil |5 |
| 103 | Eraser |3 |
Formula:
=XLOOKUP(102, A2:A4, C2:C4, "Not Found")
Result: 5
Horizontal Lookup Example:
|A |B |C |D |
|---------|----------|----------|----------|
| Item | Pen | Pencil | Eraser |
| Price | 10 |5 |3 |
Formula:
=XLOOKUP("Pencil", B1:D1, B2:D2, "Not Found")
Result: 5
Bonus:
Return multiple values:
=XLOOKUP(102, A2:A4, B2:C4)
Returns: "Pencil" and 5 in two cells.
4. IF, AND, OR Functions
------------------------
IF Function:
Used to perform a logical test and return different values for TRUE or FALSE.
Syntax:
IF(logical_test, value_if_true, value_if_false)
AND Function:
Tests multiple conditions. Returns TRUE only if all conditions are TRUE.
Syntax:
AND(condition1, condition2, ...)
OR Function:
Tests multiple conditions. Returns TRUE if at least one condition is TRUE.
Syntax:
OR(condition1, condition2, ...)
Example Table:
| Name | Math | English |
|-------|------|---------|
| Riya | 70 | 65 |
| Arjun | 40 | 55 |
| Neha | 80 | 75 |
Condition: Student passes if both marks are 50 or more.
Formula:
=IF(AND(B2>=50, C2>=50), "Pass", "Fail")
Results:
Riya => Pass
Arjun => Fail
Neha => Pass
Alternative using OR:
Condition: Student passes if either subject mark is 50 or more.
Formula:
=IF(OR(B2>=50, C2>=50), "Pass", "Fail")