How to Edit an Existing Formula in a Spreadsheet
Learn how to open, change and re-enter a spreadsheet formula in the formula bar or cell, then check the result for errors.
Editing formulas in .xlsx files is one of a common spreadsheet tasks, and it usually comes up when a formula that worked yesterday now gives the wrong number. The range has grown because new rows were added, a referenced cell was moved, or the formula was written with a typo. You need to find the formula, change only the part that is wrong, and confirm that the result is right before you move on.
This guide covers that single task: opening an existing formula, changing it, re-entering it and checking the output. It does not cover copying formulas across many cells or locking references, which are separate jobs. The steps apply to the common desktop spreadsheet apps and to most browser-based ones.
One thing to know first: a formula only exists in a spreadsheet file. If your data came to you as a PDF, the table shows the numbers as they were displayed, not the calculations behind them. Start from the original spreadsheet whenever you can.
How do you edit a formula without breaking the result? The short answer
Select the cell, open the formula for editing, change only the part that is wrong, and press Enter. Then check the result against a value you can verify yourself. The short answer covers most cases, and the table below shows how to adjust it for your situation.
| Your situation | What to do | Why |
|---|---|---|
| The formula is short and you can see it in the cell | Press F2 with the cell selected and edit it in place | You see the change in the same place where the result appears |
| The formula is long or spans several lines of logic | Click the formula bar and edit there | The bar shows the full formula, even when the cell shows only a result |
| Rows were added and the range no longer covers them | Extend the range reference, such as changing B2:B20 to B2:B25 | Formulas only read the cells they point to, so new rows are ignored |
| The result shows an error code | Find the cell or name the formula points to that is missing or misspelled | Error codes tell you what kind of problem to fix |
| You are not sure what the formula should do | Write the intended calculation in plain words first, then match the formula to it | You avoid editing toward a result you have not defined |
Before you start
- Confirm you have the spreadsheet file. Formulas exist only in spreadsheet formats such as .xlsx. A PDF or a plain CSV file keeps only the values, so you cannot change the calculation there.
- Save a copy of the file. Undo works while the file is open, but once you close it, a bad edit may be hard to reverse. A copy lets you compare the old and new versions.
- Write down what the formula should return. Pick two or three rows and work out the answer by hand. You will use these numbers to check your edit.
- Check whether the sheet or file is locked. Protected sheets and read-only files block edits, and the cell may look editable when it is not. Ask the file owner for access if you need it.
- Note which cells feed the formula. Look at the cell references and the sheet names they use. Knowing the inputs helps you spot a reference that points to the wrong place.
Editing a formula step by step
- Select the cell that holds the formula. Click the cell once. The formula bar above the grid shows the full formula, while the cell itself may show only the result.
- Open the formula for editing. Press F2 to edit inside the cell, or click into the formula bar. Either way, the cursor now sits inside the formula, so you can change it.
- Find the part to change. Use the arrow keys or click to move the cursor. Most spreadsheet apps color each cell reference in the formula, so you can see which ranges it reads.
- Change the reference, operator or function. Type over the text or delete and retype it. For example, change a range that stops at row 20 to one that stops at row 25, or fix a misspelled function name.
- Press Enter to save. Enter confirms the new formula and recalculates the cell. If you change your mind before pressing Enter, press Escape to cancel and restore the original formula.
- Check the cells that depend on this one. A formula that is copied to other cells keeps its old version in each copy. Click a neighboring cell with the same formula and decide whether it needs the same edit.
Check the result
Once you press Enter, check whether the number is right and whether any error appears. Use the table to find the problem and the fix.
| Check | How to see it | If it's wrong |
|---|---|---|
| The result matches your hand calculation | Compare the cell value with the number you worked out for two or three rows | Reopen the cell with F2 and look for a reference that points to the wrong row or column |
| No error codes appear | Look for values that start with # | #REF! means a referenced cell was deleted, #NAME? usually means a misspelled function or name, and #DIV/0! means the formula divides by zero |
| The range covers all the data | Check that the last row in the range is the last row of your data | Extend the range to include the new rows |
| Neighboring cells agree | Click a few cells that should use the same logic | Edit those cells too, or re-enter the formula in them |
| The file saved | Close and reopen the file, then check the cell again | Save again, and confirm you are working in the file you intended |
If you use a PDF or exported copy of the table, the numbers may look right while the formula is missing. Compare against the original spreadsheet before you rely on the output.
❓ FAQ
1. Why does my formula show a value but the cell looks empty or wrong?
The cell may be formatted to hide the value, or the formula may return an empty result. Select the cell and read the formula bar, which shows the formula and not the displayed text. Check the number format and the formula logic separately.
2. What does it mean when I press F2 and nothing changes?
Pressing F2 normally places the cursor inside the cell. If nothing happens, the sheet may be protected, the file may be read-only, or the cell may be locked. Check the file's permissions and ask the owner for editing access if needed.
3. Can I edit a formula inside a PDF?
Not in a meaningful way. A PDF stores the numbers as displayed, without the formulas behind them. Edit the formula in the original spreadsheet file, then export a new copy if you need a PDF.
4. Why did my result change in other cells after I edited one formula?
Those cells may refer to the cell you changed, so their results update automatically. Click each dependent cell and confirm that its formula still makes sense with the new value.
5. How do I undo an edit I already saved?
Use the undo command while the file is still open. If you have closed and saved the file, restore the copy you made before editing, which is why saving a copy first is worth the extra step.
📝 Summary
Editing a formula comes down to selecting the cell, changing the wrong part in the formula bar or cell, pressing Enter and then checking the result. Keep a copy of the file, verify two or three values by hand and look for error codes before you move on.


