How to Define a Formula in Excel: Step-by-Step
In this article
To define a formula in Excel, click the cell where you want the result, type an equals sign (=), then type the calculation or function using cell references and press Enter. For example, =A1+A2 adds two cells and =SUM(A1:A10) totals a range. That's the whole core action. Everything else — copying formulas, absolute references, error messages — builds on those four keystrokes. This guide walks through the process from a blank cell to a formula you can safely copy, plus what to do when Excel throws an error or a formula displays as text instead of calculating.
What You'll Need
- Microsoft Excel on Windows, macOS, or the web (Excel for Microsoft 365, Excel 2021, or a recent version). The steps below cover the desktop app; the web version works the same way.
- A workbook with a few numbers in it so you can test — or a blank sheet, since you can type values directly into the formula.
- Basic familiarity with clicking a cell and typing in it. No prior formula knowledge is assumed.
Step-by-Step
- Select an empty cell. Click the cell where the answer should appear. It does not need to be next to your data, though keeping it near the numbers makes reading the sheet easier.
- Type an equals sign. Press
=on your keyboard. This single character is what tells Excel "anything after this is a calculation, not text." The cell switches into edit mode and you'll see the formula appear both in the cell and in the formula bar above the sheet. - Type the calculation. For a plain arithmetic formula, use operators the way you would in a calculator:
+for add,-for subtract,*for multiply,/for divide, and^for exponent. So=10*3returns 30. Excel follows standard order of operations, so multiplication and division happen before addition and subtraction; use parentheses to force a different order, as in=(2+3)*4. - Or reference cells instead of typing numbers. Rather than
=10*3, click cell A1, type*, then click cell B1. You get=A1*B1. This is the entire point of a formula: when the numbers in A1 or B1 change, the result updates automatically. You can mix typed values and references freely, e.g.=A1*1.2to add a 20% markup. - Use a built-in function when one fits. Type
=followed by the function name and an opening parenthesis, such as=SUM(. Excel shows a suggestion list as you type; you can click the function to insert it. Then select the range with the mouse and close the parenthesis, giving=SUM(A1:A10). The colon means "through" — all cells from A1 down to A10. Common starter functions are SUM, AVERAGE, COUNT, MAX and MIN. - Check the argument order on functions that need more than a range. For
=IF(A1>100,"High","Low"), the arguments are separated by commas (semicolons in some regional settings): the test, the result if true, the result if false. Text results go in double quotation marks. Excel shows a tooltip naming each argument as you type, so read it rather than guessing. - Press Enter to commit. Excel calculates and displays the result in the cell, with the formula itself visible in the formula bar whenever the cell is selected. If you press Esc instead, the entry is cancelled and nothing changes.
- Edit a formula the same way you created it. Select the cell and press F2 (or click inside the formula bar) to enter edit mode, make changes, and press Enter. Double-clicking the cell does the same thing. Click the cell once and just start typing only if you intend to replace the whole formula.
- Copy a formula down a column. Drag the small square at the bottom-right corner of the selected cell (the fill handle) downward, or copy with Ctrl+C and paste with Ctrl+V. Reference cells shift automatically: a formula in C1 reading
=A1*B1, when copied to C2, becomes=A2*B2. This is called a relative reference. - Lock a reference when it must not move. If your formula multiplies every row by a single rate stored in, say, D1, write it as
=A1*$D$1. The dollar signs make it absolute, so copying down keeps pointing at D1 rather than sliding to D2, D3 and so on. F4 toggles the dollar signs in edit mode on Windows; on a Mac laptop you may need to check your keyboard setup because function keys often require holding the Fn key. - Name a formula if you will reuse it. For readability, you can turn a formula into a named formula: go to Formulas > Name Manager, click New, type a name such as TaxRate and put your formula in the Refers to box. You can then use
=TaxRatein any cell, and editing the name updates every place it is used. Labels here can differ slightly by version, so look for the Name Manager entry in the Formulas ribbon if the exact button moves.
Common Mistakes
- Forgetting the equals sign. Type
A1+A2without the=and Excel stores it as text — you'll see the characters sitting in the cell, not a number. Select the cell, press F2, add the=, and press Enter. - Typing numbers instead of cell references.
=10*3works once but is frozen. If the 10 lives in A1, use=A1*3so the result tracks changes. - Mixing relative and absolute references carelessly. A formula that works in the first row breaks when copied down because a locked reference was needed, or because one wasn't locked and it slid onto an empty cell.
- Leaving text unquoted.
=IF(A1>5,Yes,No)fails; Excel reads Yes and No as names. Use"Yes"and"No". - Assuming a circular reference is harmless. If a formula in A1 refers to A1, directly or through a chain, Excel warns you and results may be wrong. Check whether a range in a TOTAL or SUM accidentally includes the cell containing the total itself.
- Overwriting instead of editing. Clicking a cell and typing replaces the existing formula. Click the formula bar or press F2 when you meant to tweak it.
Tips
- Watch the colour-coded outlines Excel draws around the cells a formula refers to while you edit it — the same colour appears in the matching text in the formula bar. It is the quickest way to spot a wrong reference.
- Select a range and look at the status bar at the bottom of the window: Excel shows Sum, Average and Count for the selection without writing any formula, which is handy for a quick check before you commit.
- Keep formulas flat rather than deeply nested. A chain of AVERAGE inside IF inside ROUND is hard to audit; splitting the work across helper cells is easier to debug and no slower.
- Use a space or line break in the formula bar for readability: Ctrl+Enter on Windows or Control+Option+Enter on Mac inserts a line break inside a formula without committing it. Nothing about the calculation changes.
- Start every new complex formula with a tiny test case — two or three cells with obvious values — so you can verify the result by hand before pointing it at hundreds of rows.
Troubleshooting
The formula shows as text. The cell is probably formatted as Text, which makes Excel treat the entry literally. Select the cell, set its number format back to General, then re-enter the formula. Pasting a formula into a text-formatted cell is the usual cause.
You see ####### instead of a result. That is a column width problem, not a formula error. Widen the column, and the number appears.
A #NAME? error. Excel does not recognise a name in the formula — usually a misspelled function like =SUMM(A1:A5), or text without quotation marks. Check the spelling against the tooltip and add quotes around text.
A #VALUE! error. A cell in the calculation contains text where a number is expected, often a number stored as text or a stray space. Check whether entries are left-aligned when they should be right-aligned — a telltale sign they are text.
A #DIV/0! error. You are dividing by zero or by an empty cell. Wrap the calculation in IFERROR, as in =IFERROR(A1/B1,0), to show 0 or a blank instead of the error.
A #REF! error. A referenced cell or row was deleted. Undo the deletion with Ctrl+Z, or rewrite the formula to point at the surviving cells.
The result is wrong but no error appears. Check for a range that is off by one row — =SUM(A1:A9) when the data runs to A10 — or for a relative reference that shifted when copied. Turn on Formulas > Show Formulas (Ctrl+`) to see every formula at once and compare them across the column.
Automatic calculation seems off. If results do not refresh when inputs change, the workbook may be set to manual calculation. Check Formulas > Calculation Options and set it back to Automatic.
Frequently Asked Questions
What is the difference between a formula and a function?
A formula is any calculation starting with =, including simple arithmetic like =A1+A2. A function is a built-in tool such as SUM or IF that you call from inside a formula. Every function is part of a formula, but not every formula contains a function.
How do I show the formula instead of the result?
Click the cell and look at the formula bar above the sheet, or press Ctrl+` (the key left of the 1) to toggle Formulas > Show Formulas so the whole sheet displays its formulas.
Do formulas update when I change the source numbers?
Yes, as long as the formula uses cell references and calculation is set to automatic. Change a number in A1 and every formula pointing at A1 recalculates.
Can I define a formula once and use it in many cells?
Yes. Copy it and paste it into the other cells, or use the fill handle to drag it down or across. Excel adjusts relative references automatically; add dollar signs to any reference that should stay fixed.
Why does my SUM ignore some cells?
SUM skips text values, so numbers stored as text are not included. Look for a small green triangle in a cell corner and use the error-checking option to convert to number, or retype the value without spaces or apostrophes.
How do I delete a formula but keep the answer?
Copy the cell, then use Paste Special > Values (in the paste options) to replace the formula with its result. The number stays; the calculation link goes away.