Select the cells, press Ctrl + 1, tick Locked on the Protection tab, then go to Review › Protect Sheet and click OK.

You share a budget or timesheet with colleagues and want them to fill in only the yellow input cells, while the formulas and labels stay safe. Locking cells does nothing until you protect the sheet, so the two steps go together.
Step by step
- Select the cells you want people to be able to edit (for example the input cells) and press Ctrl + 1.
- On the Protection tab, clear the Locked tick and click OK. All cells are locked by default, so this unlocks the input cells.
- Select the cells you want to protect (or press Ctrl + A to take the whole sheet) and press Ctrl + 1 again.
- On the Protection tab, tick Locked and click OK.
- Go to Review › Protect Sheet, leave Select locked cells and Select unlocked cells ticked, and click OK.
- Try typing in a locked cell: Excel shows a message that the cell is protected. Unlocked cells still accept entries.
On a Mac: On a Mac, use Format › Cells (or Cmd + 1) for the Locked tick, and Review › Protect Sheet works the same.
Before and after
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Item | Qty | Price | Total |
| 2 | Pens | 4 | 2.5 | 10 |
| 3 | Paper | 2 | 6 | 12 |
| 4 | Clips | 10 | 0.5 | 5 |
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Item | Qty | Price | Total |
| 2 | Pens | 4 | 2.5 | 10 |
| 3 | Paper | 2 | 6 | 12 |
| 4 | Clips | 10 | 0.5 | 5 |
The macro
Press Alt+F11, choose Insert › Module, paste the code, then press F5 to run it. Save the file as .xlsm to keep the macro.
Lock all cells except B2:B4 and protect the sheet
Sub LockInputsOnly()
' Lock every cell first
Cells.Locked = True
' Then unlock the input range so users can type there
Range("B2:B4").Locked = False
' Protect the sheet with no password
ActiveSheet.Protect Password:=""
End SubWith a formula instead
| Formula | Use it when |
|---|---|
=IF(ISFORMULA(D2),"Locked","") | You only want a visual hint of which cells hold formulas; real protection still needs Protect Sheet. |
Practise it
Free exercises with instant feedback. No sign-up needed.
Common mistakes
- Cells still accept typing after you tick Locked. Locking only takes effect after you protect the sheet: go to Review › Protect Sheet.
- Users cannot type in the input cells either. Unlock those cells first (Ctrl + 1 › Protection › clear Locked) before protecting the sheet.
- You forget the protection password. Excel can't recover a sheet password. Keep it in a password manager, or protect without a password when you only want to stop accidental edits.
Questions people also ask
How do I lock only certain cells?
Unlock the cells you want editable (Ctrl + 1 › Protection › clear Locked), then protect the sheet. All other cells stay locked.
Does locking cells stop people deleting rows?
Yes, once the sheet is protected: Delete rows and Delete columns are off by default in Protect Sheet, so people can't delete them unless you tick those options.
Can I lock a whole workbook?
Yes. Use Review › Protect Workbook to stop sheets being added, deleted or renamed.
Functions used
Steps written for Excel for Microsoft 365 on Windows. All how-to guides