How to Edit a Formula in Excel
In this article
Editing a formula in Excel is a basic skill that lets you correct errors, change cell references, or update calculations without retyping everything. This guide covers the essentials: entering edit mode, using the Formula Bar, fixing broken references, and avoiding common mistakes. You don't need any special tools—just a spreadsheet with a formula already in a cell.
What You'll Need
- Microsoft Excel (2016 or later, including Microsoft 365) or Google Sheets (the steps are nearly identical).
- A spreadsheet containing at least one formula.
- Basic familiarity with cell references (like A1 or B2).
Step-by-Step
- Select the cell with the formula. Click on the cell that contains the formula you want to edit. The formula will appear in the Formula Bar above the spreadsheet grid.
- Enter edit mode. There are three ways to do this:
- Double-click the cell. This places the cursor inside the formula directly in the cell.
- Click the Formula Bar and then click inside the formula text. This is often easier for long formulas.
- Press F2 on your keyboard. This toggles edit mode on the selected cell.
- Make your changes. Use the arrow keys to move the cursor, or just click where you want to edit. You can add, delete, or replace characters. For example, change
=A1+B1to=A1*B1by replacing the plus sign with an asterisk. - Press Enter to save. After editing, press Enter to apply the change and move to the cell below. Alternatively, press Tab to save and move right, or click the checkmark in the Formula Bar.
- Press Esc to cancel. If you want to discard your edits, press Esc or click the X in the Formula Bar. This reverts the cell to its original formula.
- Check the result. After saving, verify that the new result makes sense. If it returns an error, see the Troubleshooting section below.
Common Mistakes
- Editing the wrong cell. Double-clicking a cell that contains a value (not a formula) will just place the cursor there; you might accidentally overwrite it. Always check the Formula Bar to confirm it shows a formula.
- Forgetting to press Enter. If you click another cell without pressing Enter or Esc, Excel may not apply your changes. This can lead to confusion about whether the edit was saved.
- Breaking cell references. When you edit a formula, be careful not to delete a cell reference (like A1) unless you intend to. Also, if you copy a formula to a new location, relative references adjust automatically—this is a feature, but it can cause unexpected results if you don't plan for it.
- Using the wrong operator. A common typo is using a slash
/for multiplication instead of an asterisk*. This will produce a division error. - Not using absolute references when needed. If you want a cell reference to stay fixed when copying a formula, you need to add dollar signs (e.g.,
$A$1). Without them, the reference will shift relative to the new location.
Tips
- Use the Formula Bar for long formulas. It gives you more room to see the entire formula and makes it easier to click exactly where you want to edit.
- Use F2 to quickly edit. This is the fastest way to enter edit mode without using the mouse.
- Highlight cell references. In the Formula Bar, references to other cells are often color-coded, and the corresponding cells are outlined with the same color. This helps you see which cells the formula uses.
- Press F9 to evaluate parts of a formula. In edit mode, you can select a portion of the formula and press F9 to see its computed value. This is great for debugging. Remember to press Esc afterward to avoid saving the evaluated value.
- Use the Name Manager for named ranges. If you use named ranges (like
=Sales*0.2instead of=B2*0.2), editing becomes more readable and less error-prone. - Keep formulas simple and broken into steps. Instead of one huge formula, use helper columns. This makes editing and troubleshooting much easier.
Troubleshooting
- Formula shows as text. If the cell displays the formula as plain text (e.g.,
=A1+B1appears literally), the cell is likely formatted as Text. Select the cell, change the number format to General, then re-enter the formula (press F2 and Enter). - #NAME? error. This usually means you typed a function name incorrectly or used text without quotes. Check the spelling and ensure any text in the formula is enclosed in double quotes.
- #REF! error. This indicates a reference is invalid—often because you deleted a cell that the formula depended on. Undo the deletion (Ctrl+Z) or edit the formula to point to a valid cell.
- #DIV/0! error. The formula is dividing by zero or an empty cell. Check the denominator and ensure it contains a non-zero number.
- Circular reference warning. Excel warns when a formula refers to its own cell (directly or indirectly). This can cause incorrect results or infinite calculation loops. Edit the formula to remove the self-reference.
- Changes not applied. If you edit a formula and the result doesn't update, check if manual calculation is on. Go to Formulas → Calculation Options and select Automatic.
Frequently Asked Questions
Can I edit a formula in multiple cells at once?
Yes, but it's tricky. If you select multiple cells and edit the Formula Bar, Excel will apply the same formula to all selected cells, but it will adjust relative references based on each cell's position. This is more like creating a new formula than editing existing ones. For truly editing different formulas, you need to edit each cell individually.
Why does Excel change my formula when I edit it?
Excel automatically adjusts relative cell references when you copy or move formulas. For example, if you copy =A1+B1 from row 1 to row 2, it becomes =A2+B2. This is intentional. To prevent this, use absolute references with dollar signs ($A$1).
How do I edit a formula that contains a function like VLOOKUP?
Editing a formula with functions is the same as any other formula. Enter edit mode, then modify the arguments inside the parentheses. For VLOOKUP, you might change the lookup value, table array, column index, or range lookup argument. Use the Formula Bar to see the entire function clearly.
Can I undo an edit after I press Enter?
Yes. Press Ctrl+Z (Undo) immediately after saving the edit. Excel keeps a history of your last actions, so you can undo multiple steps if needed.
Why does my formula show a #VALUE! error after editing?
This error often means the formula is trying to perform a math operation on text or empty cells. Check the cell references in the formula and ensure they contain numeric values. If you changed a reference to a cell that has text, the formula will fail.
Is there a way to see all formulas in a worksheet?
Yes. Press Ctrl+` (the backtick key, usually below Esc) to toggle formula view. This shows all formulas instead of their results, making it easier to review and edit multiple formulas at once.