🎉 Black Friday Sale: 40% OFF everything with code BF40 · ends 1 Dec  Shop now →

How to Lock Cells in Excel and Protect a Template You Share

The short version of how to lock cells in Excel: unlock the cells people should type in, then turn on Review > Protect Sheet. Every cell is locked by default, but the lock does nothing until the sheet is protected. Unlock inputs first, protect second, and test the file before you share it.

Last updated: November 2026

Key takeaways

  • All cells are Locked by default in Excel, and the setting only takes effect after you choose Review > Protect Sheet.
  • Unlock your input cells first, then protect the sheet, otherwise nobody can type anywhere.
  • Only File > Info > Protect Workbook > Encrypt with Password encrypts the file. Sheet, workbook structure and VBA passwords deter accidents, not determined people.
  • A downloaded .xlsm file may have its macros blocked until the recipient ticks Unblock in the file properties.
  • Always keep an unprotected master copy.
Excel + AI Mastery: 100 Essential Formulas courseLaunch offer
🎓 NEXTGENTEMPLATES ACADEMY
Want to build templates like these yourself?
Excel + AI Mastery: 100 Essential Formulas

SUMIFS, XLOOKUP, FILTER, LAMBDA and checking AI-written formulas, with real business projects. 11h 47m of video by PK, with practice files, quizzes and a capstone.

Which Excel protection tool does what?

Excel has several layers of protection that sound alike but do different jobs. The table below is the map for the rest of this tutorial.

ToolWhere to find itWhat it stopsEncrypts the file?
Locked / Hidden flagsFormat Cells > Protection tabNothing on its own, they only mark cellsNo
Protect SheetReview > Protect SheetEdits to locked cells on that sheetNo
Allow Edit RangesReview > Allow Edit RangesLets chosen ranges be edited by password on a protected sheetNo
Protect Workbook structureReview > Protect WorkbookAdding, deleting, renaming, moving or unhiding sheetsNo
Encrypt with PasswordFile > Info > Protect WorkbookOpening the file without the passwordYes
VBA project passwordVBA editor > Tools > VBAProject PropertiesViewing the macro codeNo

How we put this guide together

The steps are written for Excel for Microsoft 365 on the desktop. Menu names follow the ribbon labels in that version, and older versions can differ slightly. We cover the protection tools in the order you would actually apply them to a template you plan to share. We do not claim any password here is strong security, and nothing in this post is legal advice.

How to lock cells in Excel with the Locked and Hidden flags

Every cell in a new workbook carries a Locked flag that is switched on. You can see it by selecting a cell, pressing Ctrl+1 to open Format Cells and opening the Protection tab. Locked is ticked, Hidden is not.

That flag is only a label. Until you protect the sheet, you can type in locked cells freely. This is why people say that locking cells does not work: they tick Locked, see no change, and give up. The lock arrives with Protect Sheet, covered below.

The Hidden flag has one job. On a protected sheet, a hidden cell does not show its formula in the formula bar. The result still displays in the cell. Use it when you do not want a buyer reading your pricing logic, but remember that anyone with the unprotected file or a password-removal tool can still get at it.

Step 1: unlock the input cells first

  1. Select every cell where a user is meant to type: names, dates, quantities, drop-downs. Hold Ctrl to pick separate blocks.
  2. Press Ctrl+1 and open the Protection tab.
  3. Clear the Locked tick box and click OK.

If your input cells use lists, build them with data validation before you lock anything. Our guide to an Excel drop down list with data validation covers that setup, and protection then keeps the validation rules from being overwritten.

How to lock formulas in Excel with Go To Special

To lock formulas in Excel, make sure they stay locked while the cells people need are unlocked. Since locked is the default, the formulas are already locked if you never changed them. The risk is a template where someone unlocked a whole sheet. Go To Special lets you check and fix that in seconds.

  1. Click any cell, then choose Home > Find & Select > Go To Special.
  2. Select Formulas and click OK. Excel highlights every cell that holds a formula.
  3. Press Ctrl+1, open the Protection tab and tick Locked. Optionally tick Hidden to conceal the formula text.
  4. Click OK.

This is also how to protect formulas in Excel when a sheet mixes inputs and calculations: select the formula cells with Go To Special, lock them, and leave inputs unlocked. In the same dialog you can choose Constants to select typed values, which helps when you want to unlock only the typed cells in one pass.

Tip: Go To Special with Formulas also reveals stray formulas you forgot about, and that is a useful audit before you ship. Pair it with conditional formatting rules that flag problems so input cells with bad values turn colour even on a protected sheet.

How do I protect an Excel sheet and choose what users can do?

To protect Excel sheet contents, go to Review > Protect Sheet. A dialog opens with a password box and a list of check boxes headed "Allow all users of this worksheet to".

The password is optional. Leave it empty and anyone can click Unprotect Sheet, which is fine if you only want to stop accidental overwrites. Enter one and users need it to unprotect.

The allow options are where most templates go wrong. The defaults let users select locked and unlocked cells only. Tick more only when the template needs them:

  • Select locked cells and Select unlocked cells: leave both on for normal use. Turn off Select locked cells if you want the cursor to jump only between inputs.
  • Format cells, Format columns, Format rows: needed if users resize columns or change fonts.
  • Insert columns, Insert rows, Insert hyperlinks, Delete columns, Delete rows: add only when users must grow a table.
  • Sort: works on a protected sheet only when every cell in the sort range is unlocked.
  • Use AutoFilter: lets people filter, but switch the filter on before you protect the sheet.
  • Use PivotTable reports: lets people filter and rearrange existing pivot tables. Refreshing still needs the sheet unprotected, and slicers need their Locked property cleared.
  • Edit objects and Edit scenarios: control shapes, charts and scenarios.

Click OK. If you set a password Excel asks you to retype it. Write it down somewhere safe, because Excel cannot recover it for you.

Test before you ship

Try to type in a formula cell. Excel should show a message that the cell is protected. Then type in each input cell, use every drop-down, and run every filter or sort the buyer will need. Fix any blocked action by unprotecting and ticking the matching allow option.

What is Allow Edit Ranges and when do I need it?

Allow Edit Ranges (Review > Allow Edit Ranges) lets you name ranges that can be edited on a protected sheet, optionally with their own password. You set it up before you protect the sheet.

  1. Choose Review > Allow Edit Ranges and click New.
  2. Give the range a title and pick the cells.
  3. Add a range password if you want one, or leave it blank.
  4. Click OK, then protect the sheet.

A typical use is a pricing sheet where a manager range has its own password and everyone else only fills the quantity column. It is a convenience layer for a small team, not an access-control system. Excel has no user logins of its own.

How do I protect an Excel workbook structure?

Protect Excel workbook structure with Review > Protect Workbook. This blocks adding, deleting, renaming, moving, hiding or unhiding sheets. Without it, a buyer can delete your Settings tab and break every formula that points to it.

  1. Choose Review > Protect Workbook.
  2. Keep Structure ticked.
  3. Enter a password if you want one and click OK.

Structure protection does not stop anyone from editing cells. Combine it with Protect Sheet on each sheet. A hidden sheet is a common place to park lists and lookup tables, but a hidden sheet is not secret. Anyone can unhide it unless structure is protected, and even then the password is easy to bypass with free tools.

How do I password protect an Excel file so it is encrypted?

To password protect Excel file contents so they cannot be opened, use File > Info > Protect Workbook > Encrypt with Password. Enter a password, confirm it and save the file. After that, Excel asks for the password every time someone opens it.

This is the only option in this tutorial that encrypts the file. Sheet protection, workbook structure protection and the VBA password only change what Excel lets you do inside the file. They do not scramble the data.

Two cautions. First, a lost password generally cannot be recovered, so keep the master copy and the password in a safe place. Second, think about who you are protecting from. If you sell a template, encrypting it with a password you also give the buyer adds little, because the buyer can open the file and then save a copy without a password. Encryption suits files holding private data, such as payroll or customer details, that you pass to specific people.

Is the VBA project password worth setting?

If your template has macros, you can set a VBA project password. Open the VBA editor from Developer > Visual Basic (or press Alt+F11), choose Tools > VBAProject Properties, open the Protection tab, tick Lock project for viewing, enter a password and click OK. Save, close and reopen the file for it to take effect.

This stops casual viewing of your code and accidental edits to your macros. It is a deterrent, not strong security, and VBA password-removal tools exist. Do not put anything in code that must stay truly secret, such as other people's passwords or API keys.

Macro code also belongs behind good error handling, so a protected sheet does not trigger confusing run-time errors. Our guide to VBA error handling and debugging shows how to trap errors, which matters when a macro unprotects a sheet and must protect it again even if a step fails. If you are starting from zero, read Excel macros for beginners first.

How do real templates use sheet protection?

Reading how finished tools handle this is useful. Per its product page, the General Store Billing Management System ($29.00) protects its data sheets with a password that the macros use, so records go in through the checked forms. It also has Allow Record Update and Delete switches, and it has no user logins. That matches the honest view of Excel protection: it guards the data sheets against stray typing, and it does not act as a login system.

how to lock cells in excel in a billing template with protected data sheets

The Payroll Management System ($29.00) also has no separate user logins, so any pay data you keep in it is only as private as the PC and the file. If that matters to you, the File > Info > Encrypt with Password step above is the one that helps.

Payroll Management System in Excel VBA dashboard

Some tools do have logins. The Complaint Management System ($19.99) has role-based login, and the Software License Management System ($19.99) has Admin and User logins. Be clear about what the second one is: it tracks software licences a company owns. It does not license your template to buyers.

Want a finished, form-driven workbook instead of building protection yourself? The General Store Billing Management System V1.0 costs $29.00, one-time, and its page mentions a 7-day trial. For a no-macro option, the Quotation and Invoice Template in Excel and Google Sheets is $6.99.

How do I write a plain-English licence or terms-of-use sheet?

If you share or sell a template, add a visible sheet called Terms of Use or Licence as the first tab. It sets expectations before anyone gets frustrated. This is general good practice, not legal advice. If real money or risk rides on it, ask a lawyer to review the wording.

Keep it short and plain. A useful sheet covers these points:

  • Who owns the template and who may use it (for example, one named business or one person).
  • What the buyer may do: edit for their own use, print, use for their own clients.
  • What the buyer may not do: resell, redistribute or share the file, or put it on a public site.
  • A support contact and the version number.
  • A short note on what the protection is: that passwords prevent accidents and are not a security guarantee.
  • A disclaimer that the template is a tool and the buyer checks the results.

Write it in sentences a customer can read in a minute. Protect this sheet too, so the terms cannot be edited by accident.

How do I distribute a protected Excel template?

xlsx or xlsm?

A file with no macros should be saved as .xlsx. A file with macros must be .xlsm, because Excel strips macros when saving to .xlsx. Choose one on purpose. The Quotation and Invoice Template is an xlsx file with no macros, which means nothing gets blocked on opening. A buyer who sees a macro warning on a file that should have none should be suspicious.

Quotation and Invoice Template in Excel and Google Sheets dashboard

Why do macros not run on a downloaded file?

Windows marks files downloaded from the internet or received by email. Excel then blocks macros in them and shows a security message. The fix is on the recipient's side: right-click the file in File Explorer, choose Properties, tick Unblock at the bottom of the General tab, and click OK. Then open the file. Put this instruction in your delivery email or on your Terms of Use sheet, because it is the most common support question for macro files.

Version number and master copy

  • Put a version number on the Terms sheet and in the file name, such as Template-V1.2.xlsx.
  • Keep an unprotected master copy in a separate folder. If you lose the password, the master is your only way back.
  • Test the shipped file on a second PC, not the one you built it on.
  • Do your cell design first, then protect last. Changing a locked template takes unprotect, edit, reprotect each time.

Building forms is cleaner than locking a grid. See our Excel VBA UserForm tutorial for the approach of putting every entry through a checked form.

What are the common errors when you lock cells in Excel?

ProblemLikely causeFix
Nobody can type anywhereInput cells were never unlocked before protectingUnprotect, clear Locked on input cells, protect again
Locked ticked but cells still editableSheet is not protected yetReview > Protect Sheet
Sort or filter does not workSort range is locked, option not ticked, or no filter before protectingUnprotect, unlock the sort range, switch the filter on, then protect with Sort and Use AutoFilter ticked
Macro fails on a protected sheetCode writes to a locked cellUnprotect and reprotect in the code, or unlock the target cells
Macros do not run for the buyerDownloaded file is blockedProperties > Unblock, then reopen
Pivot table will not refreshIts sheet is protectedUnprotect, refresh and protect again, by hand or in code
Formulas visible in the barHidden flag not set, or sheet not protectedTick Hidden on formula cells and protect the sheet
Password forgottenNo record keptUse the unprotected master copy
Sheet layout gets brokenFormat and insert options allowed too freelyUntick Format columns, Insert rows and so on

Worked example: protecting a simple expense sheet

Say you share an expense sheet with 12 rows of inputs in A5:D16, a Total in D17 and a Terms tab. Select A5:D16 and clear Locked. Use Go To Special > Formulas to select D17 and the other formulas, then tick Locked and Hidden. Protect Sheet with no password and leave the defaults, adding Sort so users can reorder rows. Protect Workbook structure so the Terms tab stays put. Save an unprotected copy as Expenses-MASTER.xlsx and the shared copy as Expenses-V1.0.xlsx. Starting from a finished sheet saves further time, and our expense tracker Excel templates are a place to start.

When protection is NOT the right answer

  • You need real security. Sheet, workbook structure and VBA passwords are easy to remove with free tools. Use file encryption, a proper database with logins, or cloud permissions.
  • You need to know who changed what. Excel protection keeps no audit trail of its own. Use software with user accounts and logs.
  • You have many simultaneous users. A shared workbook with lots of editors is better served by a multi-user app than by locked cells.
  • You want to stop copying. Anyone who can open the file can copy values, and a buyer can copy a template they paid for.
  • The data is sensitive. Locking cells does not make private data private. Encrypt, limit who gets the file and consider whether a spreadsheet is the right place.

For reference, Microsoft’s article on how to protect a worksheet notes that worksheet protection is not intended as a security feature.

Checklists also help you ship a template without missing a step. See our business checklist templates for ideas you can adapt into a pre-release list.

Frequently asked questions

How do I lock only certain cells in Excel?

Select the cells people should edit, press Ctrl+1, open the Protection tab and clear Locked. Everything else stays locked by default. Then choose Review > Protect Sheet and click OK. Only the unlocked cells accept typing. Test by clicking a locked cell and a formula cell.

Why are my cells still editable after I locked them?

Because locking does nothing until the sheet is protected. The Locked box in Format Cells only marks the cell. Go to Review > Protect Sheet, choose your options and click OK. From then on, Excel blocks edits to locked cells and shows a message when someone tries.

How do I lock formulas in Excel but let users enter data?

Select your input cells and clear Locked in Format Cells > Protection. Use Home > Find & Select > Go To Special > Formulas to select formula cells and confirm Locked is ticked. Then use Review > Protect Sheet. Users type in inputs, and formulas stay locked.

How do I hide formulas in Excel?

Select the formula cells, press Ctrl+1, open the Protection tab and tick Hidden. Then protect the sheet with Review > Protect Sheet. The formula no longer shows in the formula bar, though the result still appears. This hides formulas from casual view and is not strong security.

Does a sheet password encrypt my Excel file?

No. A sheet password only stops edits inside Excel. The same is true for workbook structure and VBA passwords. Only File > Info > Protect Workbook > Encrypt with Password encrypts the file, so it cannot be opened without the password. Keep that password somewhere safe.

How do I protect an Excel workbook so sheets cannot be deleted?

Choose Review > Protect Workbook, keep Structure ticked, add an optional password and click OK. That stops people adding, deleting, renaming, moving or unhiding sheets. It does not stop cell edits, so also protect each sheet with Review > Protect Sheet.

What happens if I forget the Excel sheet password?

Excel cannot recover it for you. Third-party tools can remove sheet protection, but you should not rely on them. The safe habit is to keep an unprotected master copy and a note of each password in a secure place before you share the file.

Why do macros not work in a downloaded Excel file?

Windows marks files from the internet or email, and Excel blocks their macros. Right-click the file, choose Properties, tick Unblock on the General tab, click OK and reopen it. This applies to .xlsm files. A macro-free .xlsx file does not trigger the macro warning.

Should I share my template as xlsx or xlsm?

Use .xlsx if the file has no macros and .xlsm if it does. Excel removes macros when you save as .xlsx, so choose the format before you finish. An xlsx file avoids the macro block and is simpler for buyers who just need formulas and layout.

Is a VBA project password safe enough to protect my code?

It deters casual viewing and accidental edits, but it is not strong security. Password-removal tools exist for VBA projects. Do not store secrets in your code. If your code is valuable, treat the password as a courtesy lock, not a vault.

Start from a finished Excel template

Skip the setup and start from a finished workbook. The Payroll Management System V1.0 in Excel VBA and the General Store Billing Management System V1.0 are $29.00 each, one-time. The Quotation and Invoice Template is $6.99. Video walkthroughs are on the NextGenTemplates YouTube channel.

🎓 Learn to build this yourself. Excel + AI Mastery: 100 Essential Formulas · $59 launch priceStart the course →
Scroll to Top