Microsoft Excel 2024 Comprehensive Course — Beginner to Intermediate
X
Excel 2024 Microsoft 365
📗 34 Modules Foundations Data Entry Formatting Formulas Functions Charts Pivot Tables Data Analysis Protection Automation

🔍 Module 20: Rounding, VLOOKUP & Lookup Functions

Lookup functions are the bridge between separate tables of data — they find a value in one table and return related information from another. In South African offices, VLOOKUP is used daily for payroll tax tables, product pricing, employee records, customer accounts, and commission schedules. This module covers VLOOKUP in full depth, its common errors and limitations, and the modern replacements: HLOOKUP for horizontal lookups, INDEX+MATCH for flexible two-way lookups, and XLOOKUP (Excel 365) which solves every VLOOKUP limitation. Rounding is also covered fully here as it is inseparable from financial lookups and payroll calculations.

20.1 Rounding — Full Reference

Rounding functions control the precision of numeric results. Formatting a number to 2 decimal places only displays it rounded — the full unrounded value is still used in calculations. Rounding functions actually change the stored value.

All Rounding Functions at a Glance

FunctionRule15.456 to 2dp15.454 to 2dp
ROUNDStandard: 5 rounds up15.4615.45
ROUNDUPAlways away from zero15.4615.46
ROUNDDOWNAlways toward zero (truncate)15.4515.45
CEILINGUp to nearest multiple of significanceCEILING(15.456,0.05) = 15.50CEILING(15.454,0.05) = 15.50
FLOORDown to nearest multiple of significanceFLOOR(15.456,0.05) = 15.45FLOOR(15.454,0.05) = 15.45
MROUNDStandard round to nearest multipleMROUND(15.456,0.05) = 15.45MROUND(15.454,0.05) = 15.45
INTInteger — always down (negative infinity)1515
TRUNCInteger — always toward zero1515

MROUND — Rounding to Any Multiple

=MROUND(number, multiple)

=MROUND(B2, 0.05) → round to nearest 5 cents (SA retail pricing)
=MROUND(Hours, 0.25) → round to nearest quarter-hour (consultant billing)
=MROUND(Salary, 100) → round salary to nearest R100
=MROUND(Weight, 0.5) → round to nearest 0.5 kg

Rounding in Financial Contexts

Key distinction in SA payroll and invoicing:
  • Format only → =B2*0.15 displayed as "R 75.00" — the underlying value may be 75.00001 from floating point; SUM of many such values can have rounding errors
  • ROUND to fix → =ROUND(B2*0.15,2) stores exactly 75.00 — use this for VAT, UIF, and payroll deductions where cent-level accuracy is required by SARS
  • ROUNDUP for charges → =ROUNDUP(B2*0.15,2) — always round VAT up to the nearest cent (conservative approach for invoicing)

20.2 VLOOKUP — Vertical Lookup

VLOOKUP searches for a value in the leftmost column of a table and returns a value from the same row in a column you specify. The V stands for Vertical — it searches down a column.

Syntax

=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
ArgumentWhat It IsExample
lookup_value The value to search for — a cell reference, text in quotes, or number. Must match the leftmost column of the table. A2 (employee ID, product code, etc.)
table_array The table to search — must include the search column as the first (leftmost) column, plus all columns you might return. Use absolute references so the table doesn't shift when copied. $F$2:$H$100
col_index_num Which column of the table to return. Column 1 = the search column, 2 = the next column to its right, etc. 2 = return the 2nd column of the table
range_lookup FALSE (or 0) = exact match only — almost always what you want. TRUE (or 1, or omitted) = approximate match — requires the table to be sorted ascending. 0 or FALSE for exact match

VLOOKUP Step-by-Step Example

Lookup table ($F$2:$H$100):
   Col F        Col G        Col H
   EmpID       Name        Salary
   EMP001      Thabo Nkosi   R32,000
   EMP002      Ayanda Dlamini R28,500
   EMP003      Jan van Rooyen R41,000

In cell B2 (where A2 = "EMP002"):
=VLOOKUP(A2, $F$2:$H$100, 2, 0)
→ Finds "EMP002" in column F → returns column 2 (Name) → "Ayanda Dlamini"

=VLOOKUP(A2, $F$2:$H$100, 3, 0)
→ Same search → returns column 3 (Salary) → R28,500

Exact Match (FALSE/0) vs Approximate Match (TRUE/1)

ModeWhen to UseTable RequirementBehaviour if Not Found
Exact Match (0 / FALSE) Employee IDs, product codes, invoice numbers, names — any lookup where the value must match precisely Table does not need to be sorted Returns #N/A error
Approximate Match (1 / TRUE / omitted) Tax brackets, commission tiers, salary bands — where you want the largest value ≤ the lookup value Must be sorted ascending — incorrect results if unsorted Returns the closest match below the lookup value

Approximate Match Example — SA Commission Tiers

Commission table ($J$2:$K$6) — MUST be sorted ascending:
   Col J (Min Sales)      Col K (Rate)
   0                     5%
   50,000                7%
   100,000               10%
   200,000               13%
   500,000               15%

=VLOOKUP(SalesAmount, $J$2:$K$6, 2, 1)
Sales = 75,000 → finds 50,000 tier (largest value ≤ 75,000) → returns 7%
Sales = 150,000 → finds 100,000 tier → returns 10%
Sales = 600,000 → finds 500,000 tier → returns 15%

20.3 VLOOKUP Common Errors & Limitations

Error: #N/A — Value Not Found

  • The lookup value does not exist in the first column of the table
  • The lookup value is text but the table column contains numbers (or vice versa)
  • There are extra spaces in either the lookup value or the table (fix with TRIM)
  • The lookup value has a different data type — e.g., "1234" (text) vs 1234 (number)
Fix: =IFERROR(VLOOKUP(A2,$F$2:$H$100,2,0),"Not found")
Or:  =IFNA(VLOOKUP(A2,$F$2:$H$100,2,0),"Not in list")

Error: Wrong Result — Column Index Off

If col_index_num is wrong, VLOOKUP returns a value from the wrong column. Always count columns from the left edge of table_array — the first column is 1 (your search column), the next is 2, etc.

Error: Table Shifts When Copied

If table_array is not absolute ($F$2:$H$100), copying the VLOOKUP formula down shifts the table range (F3:H101, then F4:H102…) causing #N/A or wrong results. Always use absolute references for the table.

Critical Limitation 1 — Can Only Look Left to Right

VLOOKUP can only return values from columns to the right of the search column. If you need to return a value from a column to the left of the search column, VLOOKUP cannot do it. Use INDEX+MATCH or XLOOKUP instead.

Critical Limitation 2 — Inserts Break Column Index

If someone inserts or deletes a column in the lookup table, the col_index_num is now wrong (it still says "2" but the salary has moved to column 3). INDEX+MATCH avoids this by referencing columns by name, not number.

Critical Limitation 3 — Search Column Must Be First

The search value must be in the leftmost column of table_array. You cannot search a table by any middle or right column. XLOOKUP and INDEX+MATCH have no such restriction.

Handling Data Type Mismatches

If lookup value is text "1234" but table has numbers 1234:
=VLOOKUP(VALUE(A2),$F$2:$H$100,2,0) — convert lookup to number

If lookup value is number 1234 but table has text "1234":
=VLOOKUP(TEXT(A2,"0"),$F$2:$H$100,2,0) — convert lookup to text

20.4 HLOOKUP — Horizontal Lookup

HLOOKUP searches across the top row of a table and returns a value from the same column in a row you specify. H stands for Horizontal — it searches across a row instead of down a column.

Syntax

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

Arguments mirror VLOOKUP: lookup_value searches the first row; row_index_num specifies which row to return (1 = header row, 2 = first data row, etc.).

When to Use HLOOKUP

Monthly budget table — months across the top (row 1), categories down the left:

      Jan       Feb       Mar       Apr
Salaries 320,000   320,000   330,000   330,000
Rent     84,000    84,000    84,000    84,000

=HLOOKUP("Mar",$B$1:$E$3,2,0)
→ Finds "Mar" in row 1 → returns row 2 (Salaries) → 330,000

=HLOOKUP(MonthName,$B$1:$E$3,3,0)
→ Returns Rent for the month in MonthName

HLOOKUP has the same limitations as VLOOKUP. It can only return rows below the header row, and it is being replaced by XLOOKUP in modern Excel. Use INDEX+MATCH or XLOOKUP for more flexibility.

20.5 INDEX and MATCH — The Flexible Lookup Combination

INDEX and MATCH are two separate functions that, when combined, create a lookup formula more powerful and flexible than VLOOKUP. They are the professional standard in financial modelling and complex data work.

MATCH — Finding the Position

=MATCH(lookup_value, lookup_array, [match_type])

Returns the position number (row or column) of a value within a range.

=MATCH("EMP002",$F$2:$F$100,0) → returns 2 (EMP002 is the 2nd item in the range)
match_type: 0 = exact match (most common), 1 = ascending approx, -1 = descending approx

INDEX — Returning a Value by Position

=INDEX(array, row_num, [col_num])

Returns the value at the intersection of the specified row and column in a range.

=INDEX($G$2:$G$100, 2) → returns the 2nd value in column G (Ayanda Dlamini)
=INDEX($F$2:$H$100, 2, 3) → row 2, column 3 of the table (salary of 2nd employee)

INDEX + MATCH Combined — The Power Lookup

=INDEX(return_column, MATCH(lookup_value, search_column, 0))

Equivalent to VLOOKUP but more flexible:
=INDEX($G$2:$G$100, MATCH(A2,$F$2:$F$100,0))
→ MATCH finds "EMP002" in column F → returns position 2
→ INDEX goes to row 2 in column G → returns "Ayanda Dlamini"

Advantages of INDEX+MATCH Over VLOOKUP

FeatureVLOOKUPINDEX + MATCH
Look left❌ Cannot return left of search column✓ Search column can be anywhere; return column can be anywhere
Column inserts❌ col_index_num breaks when columns are inserted✓ References columns by range, not number — self-correcting
Search column position❌ Must be the leftmost column in table_array✓ Can search any column regardless of position
Performance on large dataSlightly slowerSlightly faster with MATCH on large datasets
Two-way lookup❌ Not directly possible✓ Nest two MATCH calls for row and column lookup

Two-Way Lookup with INDEX+MATCH+MATCH

Cross-tab table: rows = products (A2:A20), columns = months (B1:M1), data in B2:M20

=INDEX($B$2:$M$20,
  MATCH(ProductName,$A$2:$A$20,0),
  MATCH(MonthName,$B$1:$M$1,0))

→ Finds the row for the product AND the column for the month
→ Returns the exact intersection value (e.g., sales of Product X in March)

Left Lookup — What VLOOKUP Cannot Do

Table: Col A = Name, Col B = ID (search by ID to get Name to the LEFT)

VLOOKUP cannot do this (ID is not the leftmost column).

INDEX+MATCH can:
=INDEX($A$2:$A$100, MATCH(B2,$B$2:$B$100,0))
→ MATCH finds the ID in column B → INDEX returns column A (to the left)

20.6 XLOOKUP — The Modern Replacement (Excel 365 / 2021+)

XLOOKUP is the successor to VLOOKUP and HLOOKUP. It addresses every limitation of VLOOKUP and is simpler than INDEX+MATCH. If you have Excel 365 or Excel 2021, use XLOOKUP instead of VLOOKUP.

Syntax

=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
ArgumentWhat It IsDefault
lookup_valueThe value to search forRequired
lookup_arrayThe column (or row) to search in — can be anywhere in the tableRequired
return_arrayThe column (or row) to return the result from — can be left, right, or multiple columnsRequired
[if_not_found]What to return when no match is found — replaces IFERROR wrapper#N/A if omitted
[match_mode]0 = exact match, -1 = exact or next smaller, 1 = exact or next larger, 2 = wildcard0 (exact)
[search_mode]1 = first to last, -1 = last to first, 2 = binary asc, -2 = binary desc1 (first to last)

XLOOKUP vs VLOOKUP — Same Task, Simpler Formula

VLOOKUP (complex, fragile):
=IFERROR(VLOOKUP(A2,$F$2:$H$100,2,0),"Not found")

XLOOKUP (simple, robust):
=XLOOKUP(A2,$F$2:$F$100,$G$2:$G$100,"Not found")

No need for IFERROR wrapper, no col_index_num to manage,
search and return arrays are completely independent.

XLOOKUP Practical Examples

TaskXLOOKUP Formula
Find employee name by ID (exact match)=XLOOKUP(A2,$F$2:$F$100,$G$2:$G$100,"Not found")
Left lookup (return column to the LEFT of search)=XLOOKUP(B2,$B$2:$B$100,$A$2:$A$100,"Not found")
Return last matching entry (search from bottom)=XLOOKUP(A2,$F$2:$F$100,$G$2:$G$100,"Not found",0,-1)
Commission tier lookup (approximate, next smaller)=XLOOKUP(SalesAmt,$J$2:$J$6,$K$2:$K$6,0,-1)
Wildcard search (find by partial name)=XLOOKUP("*Dlamini*",$G$2:$G$100,$F$2:$F$100,"None found",2)
Return multiple columns (name AND salary)=XLOOKUP(A2,$F$2:$F$100,$G$2:$H$100,"Not found") (spills into 2 cells)

XLOOKUP Advantages Over VLOOKUP

  • No column index number — return_array is a direct range reference, immune to column inserts
  • Look left, right, up, or down — lookup_array and return_array are completely independent
  • Built-in not-found value — no need to wrap with IFERROR
  • Search from bottom — find the last match (not just the first)
  • Wildcard support — match_mode 2 for partial matches
  • Return multiple columns — return_array can span multiple columns
  • Horizontal lookup too — replaces HLOOKUP as well
  • Not available in Excel 2019 or earlier — use VLOOKUP or INDEX+MATCH for compatibility

20.7 Choosing the Right Lookup Function

SituationBest FunctionWhy
Simple lookup (search column on the left, return column to the right) — Excel 2019 or earlierVLOOKUPSimple syntax, widely understood, compatible with all Excel versions
Need to look left, or table structure may changeINDEX + MATCHWorks in all versions; search any column; immune to structural changes
Two-way lookup (find intersection of row and column)INDEX + MATCH + MATCHThe only pre-365 way to do cross-table two-way lookups
Horizontal lookup (data in rows)HLOOKUP or XLOOKUPHLOOKUP for older Excel; XLOOKUP replaces it entirely
Excel 365 / 2021+ and maximum flexibilityXLOOKUPSolves all VLOOKUP limitations; cleaner syntax; built-in error handling
Approximate match for tiers/bands (tax, commission)VLOOKUP (TRUE) or XLOOKUP (-1)VLOOKUP with TRUE; XLOOKUP with match_mode -1
Workbook shared with users on older Excel versionsVLOOKUP or INDEX+MATCHXLOOKUP errors in Excel 2019 and earlier; use compatible functions

20.8 SA Office Lookup Scenarios

Payroll: Employee Details from ID Number

Employee master table: ID in $A$2:$A$200, Name in $B$2:$B$200, Salary in $C$2:$C$200

VLOOKUP approach:
Employee name:  =IFERROR(VLOOKUP(D2,$A$2:$C$200,2,0),"Not found")
Employee salary: =IFERROR(VLOOKUP(D2,$A$2:$C$200,3,0),0)

XLOOKUP approach (cleaner):
Employee name:  =XLOOKUP(D2,$A$2:$A$200,$B$2:$B$200,"Not found")
Employee salary: =XLOOKUP(D2,$A$2:$A$200,$C$2:$C$200,0)

Pricing: Product Code to Price with Rounding

Price lookup table: Code in $F$2:$F$500, Price in $G$2:$G$500

Unit price:  =IFERROR(VLOOKUP(A2,$F$2:$G$500,2,0),0)
Total excl. VAT: =ROUND(B2*UnitPrice,2) — qty * price, rounded to cents
VAT amount:  =ROUND(TotalExcl*0.15,2)
Total incl. VAT: =TotalExcl+VATAmount

Tax Calculation: SA Income Tax Bracket Lookup

Tax bracket table (sorted ascending — required for approximate VLOOKUP):
Col P: threshold (0, 237100, 370500, 512800, 673000, 857900)
Col Q: base tax (0, 42678, 77362, 121475, 179147, 251258)
Col R: marginal rate (18%, 26%, 31%, 36%, 39%, 41%)

Bracket row:     =MATCH(TaxableIncome,$P$2:$P$7,1) — find which bracket
Base tax:        =INDEX($Q$2:$Q$7,MATCH(TaxableIncome,$P$2:$P$7,1))
Marginal rate:   =INDEX($R$2:$R$7,MATCH(TaxableIncome,$P$2:$P$7,1))
Bracket bottom:  =INDEX($P$2:$P$7,MATCH(TaxableIncome,$P$2:$P$7,1))
Income tax:      =BaseTax+(TaxableIncome-BracketBottom)*MarginalRate

Using VLOOKUP approximate match:
=IFERROR(VLOOKUP(TaxableIncome,$P$2:$Q$7,2,1)+(TaxableIncome-VLOOKUP(TaxableIncome,$P$2:$P$7,1,1))*VLOOKUP(TaxableIncome,$P$2:$R$7,3,1),0)

Inventory: Reorder Alert with Lookup

Products in A, Stock level in B, Reorder table (code in $E$2:$E$100, min stock in $F$2:$F$100):

Min stock level:  =IFERROR(VLOOKUP(A2,$E$2:$F$100,2,0),10)
Reorder alert:    =IF(B2<=MinStock,"REORDER NOW","Stock OK")
Units to order:   =MAX(0,TargetStock-B2)

20.9 Quick Self-Check

Q1: Write a VLOOKUP formula to find the salary of an employee whose ID is in cell A2. The employee table is in $F$2:$I$200, with ID in column F, Name in G, Department in H, and Salary in column I. Include error handling for IDs not in the table.

✓ =IFERROR(VLOOKUP(A2,$F$2:$I$200,4,0),0). The col_index_num is 4 because Salary is in the 4th column of the table_array (F=1, G=2, H=3, I=4). The 0 (or FALSE) specifies exact match — essential for IDs. IFERROR returns 0 if the ID is not found rather than showing #N/A. Using IFNA instead of IFERROR would also work and is more specific: =IFNA(VLOOKUP(A2,$F$2:$I$200,4,0),0).

Q2: The above VLOOKUP breaks when a new column is inserted between G and H in the employee table. How does INDEX+MATCH solve this problem? Rewrite the salary lookup using INDEX+MATCH.

✓ VLOOKUP uses a hardcoded col_index_num (4) which refers to column position, not the actual column. If a new column is inserted between H and I, Salary moves to column 5 but the formula still says 4, returning the wrong data silently. INDEX+MATCH avoids this by referencing the return column directly by its range address: =IFERROR(INDEX($I$2:$I$200,MATCH(A2,$F$2:$F$200,0)),0). MATCH finds the position of the ID in column F. INDEX uses that position to return the value from column I (Salary). If a new column is inserted between G and H, Excel automatically adjusts the $I$2:$I$200 reference to the new column position — the formula remains correct without any manual editing.

Q3: You have a commission rate table with minimum sales thresholds in column A (0; 50000; 100000; 200000; 500000) and rates in column B (5%; 7%; 10%; 13%; 15%). A salesperson's total sales are in cell D2. Write a VLOOKUP formula to find their commission rate. What requirement must the table meet?

✓ =VLOOKUP(D2,$A$2:$B$6,2,1). The last argument is 1 (or TRUE) for approximate match, which finds the largest value in column A that is less than or equal to D2. For sales of R150,000, it finds the 100,000 threshold and returns 10%. For R600,000, it finds the 500,000 threshold and returns 15%. Critical requirement: column A (the search column) must be sorted in ascending order. If the thresholds are out of order, the approximate VLOOKUP returns incorrect results without any error — this is a silent bug that is very hard to detect. Always verify the sort order when using approximate match.

Q4: Describe the main differences between VLOOKUP and XLOOKUP. Given a choice, when would you still use VLOOKUP instead of XLOOKUP?

✓ XLOOKUP improves on VLOOKUP in every dimension: (1) lookup_array and return_array are independent ranges, so the search column does not need to be leftmost and the return column can be anywhere including to the left; (2) there is no col_index_num that breaks when columns are inserted; (3) the [if_not_found] argument replaces the IFERROR wrapper; (4) search_mode -1 finds the last match; (5) match_mode 2 supports wildcards; (6) return_array can span multiple columns, returning several fields at once. You would still use VLOOKUP when: the workbook must work in Excel 2019 or earlier (XLOOKUP returns #NAME? in older versions); when sharing files with users whose Excel version is unknown; or in organizations where all staff must be able to understand and audit formulas and may not be familiar with XLOOKUP syntax.

Q5: Write a two-way lookup using INDEX+MATCH+MATCH. The scenario: a product sales table has product names in column A (A2:A20) and month names across the top (B1:M1), with sales figures in B2:M20. Find the sales for the product in cell P2 during the month in cell Q2.

✓ =INDEX($B$2:$M$20, MATCH(P2,$A$2:$A$20,0), MATCH(Q2,$B$1:$M$1,0)). INDEX returns the value from the data range $B$2:$M$20. The first MATCH(P2,$A$2:$A$20,0) finds the row position of the product named in P2 within column A. The second MATCH(Q2,$B$1:$M$1,0) finds the column position of the month named in Q2 within row 1. INDEX then returns the value at the intersection of that row and column. This is the standard two-way lookup formula — XLOOKUP does not natively do two-way lookup without nesting, making INDEX+MATCH+MATCH still valuable even in Excel 365.

Q6: Why is ROUND(B2*0.15,2) better than simply formatting B2*0.15 with 2 decimal places when calculating VAT for an invoice?

✓ Formatting only changes how a number is displayed — the underlying value remains the full floating-point result (e.g., 74.999999999 or 75.000000001). When formatted, it may display as "75.00" but calculations using this cell continue with the unrounded value. If you sum many such formatted-but-not-rounded VAT amounts, the total can differ from the sum of the displayed values by several cents — creating reconciliation problems and potential SARS compliance issues. ROUND(B2*0.15,2) actually changes the stored value to exactly 75.00 (two decimal places). The sum of ROUND-ed amounts always matches the sum of the displayed values exactly. For VAT invoicing and payroll, always ROUND deduction amounts rather than just formatting them, to ensure cent-level accuracy required by SARS regulations.

✓ Module 20 Complete — You Have Learned:

  • Rounding full reference — 8-function comparison table (ROUND, ROUNDUP, ROUNDDOWN, CEILING, FLOOR, MROUND, INT, TRUNC); MROUND for rounding to any multiple (5c retail, quarter-hour billing); formatting vs ROUND (display only vs store the rounded value); SA financial importance of ROUND for VAT and payroll cent-accuracy
  • VLOOKUP fundamentals — syntax with all 4 arguments; step-by-step example with employee table; exact match (FALSE/0, no sort needed, #N/A if not found) vs approximate match (TRUE/1, must be sorted ascending, returns closest below); commission tier example with approximate match
  • VLOOKUP errors — #N/A causes (not found, data type mismatch, extra spaces); fix with IFERROR/IFNA; col_index_num off by one; table not absolute (shifts when copied); TRIM to fix space issues; VALUE/TEXT to fix type mismatches
  • VLOOKUP limitations — can only look left-to-right; col_index_num breaks on column inserts; search column must be leftmost; all three solved by INDEX+MATCH or XLOOKUP
  • HLOOKUP — horizontal equivalent (searches first row, returns row by index); same limitations as VLOOKUP; replaced by XLOOKUP
  • INDEX + MATCH combination — MATCH returns position; INDEX returns value at that position; combined as =INDEX(return_col, MATCH(lookup,search_col,0)); advantages over VLOOKUP (look left, immune to column inserts, search any column); two-way lookup with INDEX+MATCH+MATCH; left lookup example
  • XLOOKUP (Excel 365/2021+) — syntax with 6 arguments (lookup_value, lookup_array, return_array, if_not_found, match_mode, search_mode); 6 practical examples; 7 advantages over VLOOKUP; when to still use VLOOKUP (compatibility with Excel 2019 and earlier)
  • Choosing the right function — 7-row decision table (simple lookup, left lookup, two-way, horizontal, 365+, approximate tiers, shared workbook compatibility)
  • SA office scenarios — payroll employee details (VLOOKUP and XLOOKUP versions); product pricing with VAT rounding; SA income tax bracket lookup with INDEX+MATCH; inventory reorder alerts with VLOOKUP

← Back to All Modules