Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel Formulas and Functions: How They Work

· 6 min read · Home Tech

In this article
  1. What Exactly Is a Formula vs. a Function?
  2. How to Write a Formula: Syntax and Operators
  3. Common Functions and When to Use Them
  4. How to Choose Between VLOOKUP, INDEX/MATCH, and XLOOKUP
  5. Common Errors and How to Fix Them
  6. Array Formulas and Dynamic Arrays
  7. Performance and Limits
  8. Frequently Asked Questions

Excel formulas and functions are the built-in calculation engine that lets you turn raw data into results: a formula is any expression you type starting with = (like =A1+B1), while a function is a predefined operation such as SUM or VLOOKUP that you call with arguments. This article explains the difference, how to write and debug them, and which ones to use for common tasks.

What Exactly Is a Formula vs. a Function?

A formula is any user‑written expression that returns a value. It can be as simple as =A1*2 or as complex as =(B1+B2)/(C1-C2). A function is a named, built‑in procedure that takes inputs (arguments) and returns a result. For example, =SUM(A1:A10) is a formula that uses the SUM function. Every function call is part of a formula, but not every formula uses a function.

Functions are organized into categories: Math & Trig (e.g., ROUND, SQRT), Statistical (AVERAGE, STDEV), Lookup & Reference (VLOOKUP, INDEX), Text (LEFT, CONCATENATE), Date & Time (TODAY, DATEDIF), Logical (IF, AND), and more. As of Excel 365, there are over 450 functions.

How to Write a Formula: Syntax and Operators

All formulas begin with an equals sign =. After that, you combine cell references, numbers, text (in double quotes), and operators:

  • Arithmetic: +, -, *, /, ^ (exponent)
  • Comparison: =, <>, >, <, >=, <= (return TRUE/FALSE)
  • Text concatenation: & (e.g., =A1&" "&B1)
  • Reference operators: colon : for a range, comma , for union, space for intersection

Excel follows standard math order of operations: parentheses first, then exponentiation, then multiplication/division, then addition/subtraction. For example, =2+3*4 returns 14, not 20. To force 20, write =(2+3)*4.

Common Functions and When to Use Them

Here are the functions most users reach for daily, with their typical use:

  • SUM – adds numbers: =SUM(A1:A10)
  • AVERAGE – arithmetic mean: =AVERAGE(B1:B10)
  • IF – conditional logic: =IF(C1>=60,"Pass","Fail")
  • VLOOKUP – find a value in the first column of a table and return a value in the same row: =VLOOKUP(D1,A2:B10,2,FALSE)
  • COUNTIF / SUMIF – count or sum cells that meet a condition: =COUNTIF(A1:A10,">5")
  • INDEX + MATCH – more flexible lookup than VLOOKUP (can look left, works with unsorted data)
  • TEXT – format a number as text: =TEXT(A1,"0.00")
  • DATE / YEAR / MONTH – build or extract parts of dates

For example, to find the second‑largest value in a list, use =LARGE(A1:A10,2); to remove extra spaces, use =TRIM(A1).

How to Choose Between VLOOKUP, INDEX/MATCH, and XLOOKUP

If you are using Excel 365, XLOOKUP is the simplest and most powerful lookup function. It can search from left to right, return a default if not found, and handle arrays. For example: =XLOOKUP(D1,A2:A10,B2:B10,"Not found").

For older versions, VLOOKUP works well when your lookup column is the leftmost column of the table and you need an exact match. INDEX/MATCH is more flexible: it can look up to the left and does not break when you insert a column in the table. A common pattern is =INDEX(B2:B10,MATCH(D1,A2:A10,0)).

Rule of thumb: use XLOOKUP if you have it; otherwise use INDEX/MATCH for anything beyond a simple left‑to‑right exact match.

Common Errors and How to Fix Them

Excel shows error values that give clues:

  • #DIV/0! – you divided by zero or an empty cell.
  • #NAME? – Excel doesn’t recognize a function name (typo) or text without quotes.
  • #VALUE! – the wrong type of argument (e.g., text where a number is expected).
  • #REF! – a reference is invalid, often after deleting a row/column used in the formula.
  • #N/A – a lookup didn’t find a match (often fixed by using FALSE for exact match).
  • #NUM! – an invalid numeric value, like a negative square root.

To debug, click the cell and use Trace Precedents (Formulas tab) to see which cells feed the formula. Also, evaluate the formula step‑by‑step with Evaluate Formula. A frequent mistake is mixing up absolute and relative references: if you copy a formula down and the reference moves when it shouldn’t, add $ (e.g., $A$1 locks both column and row).

Array Formulas and Dynamic Arrays

In modern Excel, many formulas automatically spill results into multiple cells. For example, =A1:A5*B1:B5 returns five values in a vertical array. These are called dynamic arrays. Older Excel required pressing Ctrl+Shift+Enter to enter array formulas; that is no longer necessary in Excel 365. Functions like FILTER, SORT, UNIQUE, and SEQUENCE are new dynamic array functions that make complex tasks easier. For instance, =SORT(UNIQUE(A1:A100)) returns a sorted list of unique values.

Performance and Limits

Excel can handle up to 1,048,576 rows and 16,384 columns per sheet. Formulas that reference entire columns (e.g., =SUM(A:A)) are convenient but can slow down calculation because Excel checks every cell in that column. Use explicit ranges like A1:A10000 when possible. Volatile functions like TODAY() and RAND() recalculate every time the sheet changes, which can also slow large workbooks. To reduce calculation load, set calculation to manual (Formulas tab → Calculation Options) and press F9 to recalculate when needed.

Frequently Asked Questions

What is the difference between a formula and a function?

A formula is any expression starting with =, while a function is a predefined operation used inside a formula. For example, =A1+B1 is a formula without a function; =SUM(A1:B1) is a formula that uses the SUM function.

Why is my VLOOKUP returning #N/A?

Most often because the lookup value is not found in the first column of the table, or because you used TRUE (approximate match) and the first column is not sorted. Use FALSE for exact match, and check for extra spaces or numbers stored as text.

How do I keep a cell reference constant when copying a formula?

Use absolute references by adding dollar signs: $A$1 locks both column and row, A$1 locks only the row, and $A1 locks only the column. Press F4 while editing a reference to cycle through these.

Can I use a formula across different sheets?

Yes. Reference another sheet by name: =Sheet2!A1 or =SUM(Sheet2:Sheet5!A1) to sum the same cell across multiple sheets. If the sheet name has spaces, put it in single quotes: ='My Sheet'!A1.

What does the #SPILL! error mean?

It means a dynamic array formula wants to output into cells that are not empty. Clear the obstructing cells, or move the formula to a location with enough space. The error also appears if the formula is inside a table that blocks spill.

How do I learn to write my own functions?

Start by reading the function syntax from Excel’s help (press F1 and search for the function name). Practice on small datasets, use the Insert Function dialog (fx button) to see arguments, and gradually combine functions. For custom behavior beyond built‑ins, you can write user‑defined functions in VBA, but that requires programming knowledge.