How-to recipes · Workbooks and sheets
How to lock formula cells in Excel
Protect formulas from being overwritten while leaving input cells editable: unlock inputs, lock formulas with Go To Special, and protect the sheet.
You built a careful order form or budget, shared it, and a week later the totals are wrong because someone typed a number over a formula. Excel can prevent this: lock the cells that contain formulas, leave the input cells open, and turn on sheet protection. It takes a minute and works the same in Microsoft 365, Excel 2016 and 2019 and on Mac. The key is understanding that locking a cell does nothing until the sheet is protected.
How locking works
Every cell has a Locked setting, found in Format Cells > Protection, and it is on for all cells by default. It has no effect until you choose Review > Protect Sheet. Then every locked cell becomes read-only, and only unlocked cells can be edited. So the job is: unlock everything, lock only the formulas, then protect.
Step 1: find the formula cells
It helps to see which cells contain formulas before protecting them. ISFORMULA returns TRUE for a formula cell, and works as a conditional formatting rule too:
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Item | Qty | Price | Total | Formula? |
| 2 | Paper | 10 | 4.5 | 45 | TRUE |
| 3 | Toner | 2 | 62 | 124 | |
| 4 | Pens | 25 | 0.8 | 20 |
D2 holds =B2*C2, so ISFORMULA returns TRUE. The quantities and prices are typed values and would return FALSE.
Result: TRUE
Press Ctrl with the grave-accent key (the key above Tab, left of 1) to switch the whole sheet into formula view and back. FORMULATEXT shows the formula of another cell as text, for example =FORMULATEXT(D2) displays =B2*C2, which is handy for documentation.
Step 2: unlock all cells
- Select all cells with Ctrl+A (or click the triangle at the top-left corner of the grid).
- Press Ctrl+1 [Mac: Cmd+1] to open Format Cells and go to the Protection tab.
- Untick Locked and click OK.
Step 3: lock only the formulas
- With the sheet still selected, press F5 (Go To) and click Special. On Mac, use Edit > Find > Go To > Special.
- Choose Formulas (keep all four types ticked) and click OK. Excel selects every formula cell on the sheet.
- Press Ctrl+1, go to Protection, tick Locked (and Hidden if the formulas should not be visible in the formula bar), and click OK.
Labels and headers are not formulas, so they stay unlocked after step 2. If you also want to protect them, select them and lock them in the same way.
Step 4: protect the sheet
- Go to Review > Protect Sheet.
- Optionally enter a password. Without one, anyone can unprotect the sheet from the same menu, which is fine for preventing accidents.
- In the list Allow all users of this worksheet to, keep Select locked cells and Select unlocked cells. Tick Format columns, Sort or Use AutoFilter if users need them.
- Click OK (and confirm the password).
Now typing in D2 shows a message that the cell is protected, while B2 and C2 accept input. To change a formula later, choose Review > Unprotect Sheet.
Making inputs obvious
Give unlocked input cells a light yellow fill so users know where to type. You can do it automatically with a conditional formatting rule =NOT(ISFORMULA(B2)) or =CELL("protect",B2)=0, which uses CELL to test the Locked setting. Pressing Tab on a protected sheet jumps between unlocked cells only, which makes forms quick to fill in.
Tables and protected sheets
Excel tables cannot add new rows while the sheet is protected, even if the cells below are unlocked. For lists that must grow, either leave enough unlocked empty rows inside the table, or use Review > Allow Edit Ranges together with protection. VBA can also protect a sheet with UserInterfaceOnly:=True, so macros may still change it, as shown in VBA best practices: clean code, sharing and security.
Pitfalls
- Forgetting step 2. If you skip unlocking, protection makes the whole sheet read-only.
- Sheet passwords are not security. They stop accidents and casual edits, not a determined user; they can be removed with widely available tools. Do not use them to hide confidential data. For real confidentiality, encrypt the file (File > Info > Protect Workbook > Encrypt with Password).
- Lost passwords cannot be recovered by Microsoft. Store them safely.
- Workbook vs sheet protection. Protect Workbook (structure) prevents adding, deleting or renaming sheets; it does not protect cells. Use both if needed.
- New formulas added after protection need to be locked too; repeat steps 3-4 after changes.