Smart Systems for Home

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

Excel Lock Protect Formulas: How to Hide and Guard

· 5 min read · Home Tech

In this article
  1. Why Lock and Protect Formulas?
  2. How Excel Locking Actually Works
  3. Step-by-Step: Lock and Hide Formulas
  4. Choosing What Users Can Do
  5. Common Problems and Fixes
  6. Workbook vs. Worksheet Protection
  7. Alternatives to Locking Formulas
  8. Frequently Asked Questions

Yes, Excel can lock and protect formulas so they cannot be edited or viewed. You do this by locking the formula cells, protecting the worksheet, and optionally hiding the formulas in the formula bar. This article explains the exact steps, the difference between locking and hiding, how to allow edits in other cells, and common problems you might run into.

Why Lock and Protect Formulas?

When you share a workbook, anyone with edit permissions can click a formula cell and see the formula in the formula bar, or press F2 and change it. Even if they don't mean to, a stray keystroke can overwrite a formula and break the whole sheet. Locking and protecting formulas prevents accidental edits and keeps your logic private. The protection is not strong security—it's a deterrent. Anyone determined enough can unprotect the sheet if they know the password, so treat it as a safeguard, not encryption.

How Excel Locking Actually Works

Every cell in Excel has a Locked property, but it does nothing until you turn on worksheet protection. By default, all cells are locked. When you protect the sheet, every locked cell becomes read-only. Cells that are not locked remain editable. This two-step system is the key to protecting formulas while leaving input cells open.

There is also a Hidden property for formulas. When a cell is hidden and the sheet is protected, the formula does not show in the formula bar when you select the cell. The result still displays in the cell, but the underlying formula is invisible. Hidden only affects the formula bar, not the cell value.

Step-by-Step: Lock and Hide Formulas

  1. Select all cells in the worksheet (Ctrl+A) and open Format Cells (Ctrl+1). On the Protection tab, uncheck Locked. This unlocks everything so you can later lock only the formula cells.
  2. Press F5 or Ctrl+G to open Go To, click Special, choose Formulas, and click OK. This selects every cell that contains a formula.
  3. With those cells still selected, open Format Cells again. On the Protection tab, check Locked and optionally check Hidden if you don't want the formula to appear in the formula bar.
  4. Go to the Review tab and click Protect Sheet. Set a password if you want, and choose what users can do. The default allows selecting cells but not editing locked ones.

After this, formula cells are protected and hidden, while input cells (which you unlocked) remain editable. Users can type values into unlocked cells and the formulas recalculate, but they cannot see or change the formulas.

Choosing What Users Can Do

When you protect a sheet, a dialog box lists permissions like Select locked cells, Select unlocked cells, Format cells, Sort, and Use PivotTable. The default setting lets users select both locked and unlocked cells, which is usually what you want. If you uncheck Select locked cells, users cannot even click on a formula cell, which can be confusing. Keep that checked unless you have a specific reason not to.

If you want users to be able to add new rows or columns, you must allow Insert rows and Insert columns in the protection dialog. But inserting a row inside a protected range can shift formulas and break things, so only enable it if you understand the consequences.

Common Problems and Fixes

  • Formulas still visible after protecting: You forgot to check Hidden in Format Cells before protecting. Unprotect, select the formula cells, check Hidden, and re-protect.
  • Users can't edit input cells: You locked all cells instead of unlocking them first. Unprotect, select all cells, uncheck Locked, then lock only the formula cells.
  • Forgot the password: There is no official way to recover a lost worksheet protection password. You can unprotect if you know the password, or use a third-party tool, but that's outside Excel's normal functions.
  • Protection doesn't stop copying: If a user copies a protected cell and pastes it elsewhere, the formula may paste as a value or as a formula depending on paste options. Protection does not prevent copying.

Workbook vs. Worksheet Protection

Worksheet protection locks individual cells. Workbook protection locks the structure of the workbook—such as moving, deleting, or renaming sheets. To protect the workbook structure, go to Review > Protect Workbook and check Structure. This is useful if you don't want users to hide or delete sheets. It does not lock formulas by itself; you still need worksheet protection for that.

Alternatives to Locking Formulas

If you want to share the result without any chance of formula tampering, you can convert formulas to values: copy the cells, paste as values (Ctrl+Shift+V). This removes the formulas entirely, so nothing to protect. But you lose the ability to recalculate. Another option is to save the file as PDF or publish to Excel Online with view-only permissions. For more robust security, you could move the calculation to a backend system, but that's beyond Excel's built-in features.

Frequently Asked Questions

Can I protect formulas without protecting the whole sheet?

No. The Locked property only takes effect when the sheet is protected. You can, however, unlock all cells except the formula cells, so the sheet is protected but only the formula cells are actually restricted. Users can still edit input cells.

Does protecting formulas hide them from the formula bar?

Only if you also check the Hidden box in Format Cells. Locking alone prevents editing but still shows the formula in the formula bar. Hidden is a separate property that must be set before protecting.

Can users still copy the result of a protected formula?

Yes. Protection prevents editing, not copying. Users can copy the displayed value and paste it elsewhere. If you want to prevent copying, you would need to disable selection entirely, which is usually not practical.

Is there a way to unprotect a sheet if I forgot the password?

If you forget the password, there is no official Excel feature to recover it. You can try to remember it or use a third-party password recovery tool, but that is not supported by Microsoft and may not work on newer file formats.

Does protecting formulas work in Excel Online or Google Sheets?

Excel Online supports worksheet protection, but the steps are slightly different. In Google Sheets, you can protect ranges and sheets under Data > Protected sheets and ranges. The concept is similar: lock cells, then set permissions.

Why does my protection not work after I share the file?

If you share the file and the recipient opens it in an older version of Excel, protection may behave differently. Also, if the file is in XLSX format, protection is applied to the worksheet, but if the user has edit permissions in the shared location, they can still unprotect it if they know the password. Ensure you set a strong password and share as read-only if possible.