How to lock a cell in excel
Tutor 5 (70 Reviews)
Excel Tutor
Still stuck with a Excel question
Ask this expertAnswer
To lock a cell in Excel, you must protect the worksheet after selecting which cells to lock. Excel locks all cells by default, so you need to unlock the cells you want to remain editable, then apply worksheet protection.
Steps to Lock Specific Cells
- Select the cells you want to keep unlocked (editable)
- Right-click and choose "Format Cells" (or press Ctrl+1 on Windows, Cmd+1 on Mac)
- Navigate to the Protection tab
- Uncheck the "Locked" checkbox
- Click OK
- Go to the Review tab in the ribbon
- Click "Protect Sheet"
- Set a password (optional but recommended)
- Choose which actions users can perform
- Click OK
Understanding Cell Locking Mechanism
Cell locking works through a two-step system. The "Locked" property exists on every cell, but this property takes effect only when worksheet protection is active. Without worksheet protection enabled, the locked status has no impact on cell editability.
Unlocking All Cells Before Selective Locking
You may want to unlock all cells first, then lock only specific ones. Select all cells by clicking the triangle at the intersection of row and column headers (or press Ctrl+A on Windows, Cmd+A on Mac). Open Format Cells, go to the Protection tab, and uncheck "Locked." After this, select only the cells you want to protect, return to Format Cells, and check the "Locked" box.
Worksheet Protection Options
When you click "Protect Sheet," Excel presents several permission options:
- Select locked cells
- Select unlocked cells
- Format cells
- Format columns
- Format rows
- Insert columns
- Insert rows
- Insert hyperlinks
- Delete columns
- Delete rows
- Sort
- Use AutoFilter
- Use PivotTable reports
- Edit objects
You control which actions remain available after protection.
Password Protection Considerations
Setting a password prevents unauthorized users from unprotecting the sheet. Excel passwords use encryption, but worksheet-level passwords offer basic protection rather than military-grade security. Anyone with password recovery tools can potentially break worksheet protection, though it requires specialized software.
Locking Cells with Formulas
Protecting cells containing formulas prevents accidental deletion or modification. Follow these steps:
- Press Ctrl+G on Windows (F5 on Mac) to open the Go To dialog
- Click "Special"
- Choose "Formulas"
- Click OK to select all formula cells
Once selected, ensure these cells have the "Locked" property checked before protecting the sheet.
How to Unlock Protected Cells
To unlock protected cells, go to the Review tab and click "Unprotect Sheet." Enter the password if one was set. After unprotection, you can modify the locked status of any cell through Format Cells.
Differences Between Windows and Mac
The keyboard shortcuts and menu locations differ slightly between platforms:
- Format Cells: Ctrl+1 on Windows, Cmd+1 on Mac
- Go To dialog: Ctrl+G on Windows, F5 on Mac
- Select All: Ctrl+A on Windows, Cmd+A on Mac
The menu locations and ribbon structure remain identical across both platforms.
Protecting Multiple Worksheets
You must protect each worksheet individually. Excel does not offer a single command to protect all worksheets simultaneously in the standard interface. You can use VBA (Visual Basic for Applications) to loop through worksheets and apply protection to each one programmatically.
Workbook-Level Protection vs. Worksheet-Level Protection
Workbook protection differs from worksheet protection. Workbook protection (File > Info > Protect Workbook) prevents structural changes like adding, deleting, hiding, or renaming sheets. Worksheet protection prevents cell editing and other modifications within a specific sheet. You can apply both types simultaneously for comprehensive protection.
Hidden Cell Protection
Cells have two protection properties in the Protection tab:
- Locked: Prevents editing of cell content when worksheet protection is active
- Hidden: Conceals formulas in the formula bar when worksheet protection is active
Users can still see the cell values but cannot view the underlying formulas when the Hidden property is enabled.
Allowing Specific Users to Edit Ranges
Excel provides granular control through "Allow Users to Edit Ranges" in the Review tab. This feature offers:
- Ability to define specific cell ranges that certain users can edit with passwords
- Individual password assignment for each range
- Different editing permissions for different users on the same protected sheet
This approach provides more flexibility than standard worksheet protection.
Can You Lock Cells in Excel Online?
Yes, you can lock cells in Excel Online. The process mirrors the desktop version: format cells to set locked properties, then protect the sheet through the Review tab. The interface presents the same options for worksheet protection and password settings.
Removing Protection from Multiple Cells
Select multiple cell ranges by holding Ctrl (Windows) or Cmd (Mac) while clicking different areas. Open Format Cells and change the locked status for all selected ranges simultaneously. This approach saves time when you need to modify protection settings across non-contiguous cells.
Locked Cell Error Messages
When users attempt to edit a locked cell on a protected sheet, Excel displays: "The cell or chart you're trying to change is on a protected sheet." This message indicates worksheet protection is active and the cell has the "Locked" property enabled.
Protection in Shared Workbooks
Shared workbooks have limited protection capabilities. Many protection features become unavailable when you enable workbook sharing. You must choose between full protection features and workbook sharing, as Excel restricts combining both functionalities in older file formats.
Protecting Cells While Allowing Filtering
Enable the "Use AutoFilter" option in the Protect Sheet dialog to let users filter data without unprotecting the worksheet. Users can apply filters, sort filtered results, and interact with filter dropdown menus while cell contents remain locked.
VBA Method for Locking Cells
You can lock cells programmatically using VBA. The code Range("A1:B10").Locked = True sets the locked property, while ActiveSheet.Protect Password:="yourpassword" enables protection. This method benefits users who need to automate protection across multiple workbooks or apply complex conditional locking rules.
Does Locking Cells Affect Formulas Referencing Them?
No, locking cells does not affect formulas that reference those cells. Locked cells can still be referenced by formulas in unlocked cells. The locked status only prevents direct editing of the cell content, not reading values from the cell.
Conditional Formatting on Locked Cells
Conditional formatting continues to work on locked cells after worksheet protection. The formatting rules update automatically based on cell values or formula results. You must allow "Format cells" in the protection options for users to modify existing conditional formatting rules.
Locking Cells in Tables
Tables (structured references) can have locked cells just like regular ranges. Convert a range to a table using Ctrl+T (Cmd+T on Mac), then apply cell locking normally. Table functionality like filtering and sorting works on protected sheets when you enable the appropriate permissions.
Protection Indicator in Excel
Excel handles locked cell indication as follows:
- No visual indicator shows which cells are locked until you attempt to edit a protected cell
- You can view each cell's locked status by selecting it and opening Format Cells to check the Protection tab
Best Practices for Cell Locking
Follow these recommendations for effective cell protection:
- Document which cells are locked and why, especially in shared workbooks
- Use descriptive passwords you can remember or store securely
- Test the protection by trying to edit various cells after enabling protection
- Consider using "Allow Users to Edit Ranges" for complex permission requirements rather than creating multiple versions of the same workbook
Get Online Tutoring or Questions answered by Experts.
You can post a question for a tutor or set up a tutoring session
Answers · 1
How to add secondary axis in excel
Answers · 1
How to switch columns to rows in excel
Answers · 1
How to subtract on excel
Answers · 1
How to combine two cells of text in excel
Answers · 1