How to Protect Specific Cells in Excel​ (5 Suitable Ways)

Protecting specific Excel cells from editing prevents unwanted changes, deletions, and data loss. By default, all cells in Excel are set as Locked. However, locking has no effect until you lock the sheet using the Protect Sheet feature.

Therefore, to protect specific cells, first, you must unlock the cells you want to remain editable. After that, apply sheet protection so that the remaining cells stay locked.

Key Takeaways

Follow the steps given below to protect specific cells from editing:

➤ Select the entire sheet, right-click, and choose Format Cells. In the new window, go to the Protection tab >> uncheck Locked >> press Ok.
➤ Click and drag to choose the range of cells you want to lock, open the Home tab >> Format drop-down >> Lock Cell.
➤ Finally, go to the Review tab >> Protect Sheet >> set a password (optional) and choose permissions (e.g., allow formatting, sorting, etc.). Click Ok.

overview image

This article covers all the ways of locking specific cells in a sheet using the Protect Sheet feature, the Allow Edit Range option, and VBA coding.

Download Practice Workbook
1

Lock Cells Using the Format Cells and Protect Sheet Features

In our sample project task dataset, we have columns for employee names, tasks, assigned dates, deadlines, and status. We want to lock the first 4 columns (A1:D10) while keeping the last column (Column E) editable.

Lock Cells Using the Format Cells and Protect Sheet Features

To protect specific cells that you select, follow the steps given below:

➤ First, we need to unlock all cells. For this, select all cells in your worksheet by clicking the triangle at the intersection of the row numbers and column letters (or press CTRL + A).
Right-click on your selection and choose the Format Cells option from the menu.

Lock Cells Using the Format Cells and Protect Sheet Features

➤ As Excel opens the Format Cells dialog box, click on the Protection tab, uncheck the Locked box, and press Ok.

Lock Cells Using the Format Cells and Protect Sheet Features

➤ Now, select the cells you want to lock. We’re choosing the range A1:D10. Click and drag to select adjacent cells. For non-adjacent cells, press and hold the  Ctrl  key while you click on individual cells or drag to select ranges of cells you want to include.
➤ Go to the Home tab and click on the Format drop-down in the Cells group.

Lock Cells Using the Format Cells and Protect Sheet Features

➤ Choose Lock Cell from the menu (located under the protection group).

Lock Cells Using the Format Cells and Protect Sheet Features

➤ Click on the Format drop-down again (or go to the Review tab) and choose Protect Sheet this time.

Lock Cells Using the Format Cells and Protect Sheet Features

➤ In the Protect Sheet pop-up, you can type a password or leave the password field empty. Check or uncheck the boxes to give special permissions such as formatting, deleting, or adding columns and rows. Press Ok when you’re done.

Lock Cells Using the Format Cells and Protect Sheet Features

➤ When prompted, retype your password and click Ok.

Lock Cells Using the Format Cells and Protect Sheet Features

➤ Excel will now lock the cells you’ve selected, displaying the following warning for any edit attempts.

Lock Cells Using the Format Cells and Protect Sheet Features

➤ However, the cells you haven’t locked remain editable like the range E1:E10 in our dataset.

Lock Cells Using the Format Cells and Protect Sheet Features


2

Lock All Cells Except the Editable Ones

In this method, we’ll keep certain cells editable while others stay protected. Here’s how:

➤ Select the range of cells you want to keep editable for the users (E2:E10). Right-click on your selection and choose Format Cells.

Lock All Cells Except the Editable Ones

➤ From the new window, go to the Protection tab >> uncheck Locked >> press Ok.

Lock All Cells Except the Editable Ones

➤ Click on the Review tab >> Protect Sheet. Set a password (optional) and click Ok. Reenter your password and press Ok.

Lock All Cells Except the Editable Ones

➤ Excel will now protect the entire sheet except for the cells you selected.


3

Protect Specific Cells with the Allow Users to Edit Ranges Option

If multiple people are working on the same sheet and you want to give different users access to certain cells, follow the steps given below:

➤ Go to the Review tab and select Allow Edit Ranges from the Protect group.

Protect Specific Cells with the Allow Users to Edit Ranges Option

➤ In the new window, click on the New button and Excel will open the New Range dialog box.

Protect Specific Cells with the Allow Users to Edit Ranges Option

➤ Give your range a name (e.g., Range1, MyRange) in the Title box. Proceed to the Refers to Cells field and specify the range of cells you want to make editable (E2:E10).
➤ Now, you can apply two optional settings. Use the Password button to set a password to edit this specific range. You can also click on Permissions to give edit access to specific persons (for User-Level Security). When you’re done, click Ok.

Protect Specific Cells with the Allow Users to Edit Ranges Option

➤ As the Allow Users to Edit Range window reappears, click on Protect Sheet.

Protect Specific Cells with the Allow Users to Edit Ranges Option

➤ Set a password if needed and press Ok. Retype your password when prompted. Click Ok.
➤ From now on, users can only edit the selected cells in Column E while others remain protected.


4

Only Protect Cells with Formulas with the Go To Special Feature

With Excel’s Go To Special feature, you can highlight specific cells containing formulas, blanks, comments, etc. Once highlighted, we can use the Protect Sheet feature to lock those cells. Here’s how:

➤ Select your entire dataset, right-click, and click Format Cells. From the Format Cells window, go to the Protection tab >> uncheck Locked >> click Ok.
➤ Highlight your data range, press  Ctrl  +  G  to open the Go To dialog box, and click on Special.

Only Protect Cells with Formulas with the Go To Special Feature

➤ Depending on the type of cells you want to lock click on any of the given options. We chose Formulas. Click Ok.

Only Protect Cells with Formulas with the Go To Special Feature

➤ As Excel highlights the cells containing formulas (D2:D10), click on the Home tab >> Format drop-down >> Lock Cell.

Only Protect Cells with Formulas with the Go To Special Feature

➤ Go to the Review tab >> Protect Sheet >> set a password (optional) >> Ok. Reenter if prompted and press Ok.

Only Protect Cells with Formulas with the Go To Special Feature

➤ Excel will now lock the cells with formulas and keep the remaining cells editable.


5

Use VBA to Lock Cells

With a VBA macro, you can specify the cells or ranges you want to protect with or without a password. Here are the details:

Right-click on the sheet name and choose View Code from the menu.

Use VBA to Lock Cells

➤ In the blank field, copy and paste the following code:

Sub LockSelectedCells()
    Dim rng As Range
    Dim pwd As String
    Dim ws As Worksheet
    Set ws = ActiveSheet
    ' Ask user to select cells
    On Error Resume Next
    Set rng = Application.InputBox("Select the cells or ranges you want to lock:", _
                                   "Lock Cells", Type:=8)
    On Error GoTo 0
    If rng Is Nothing Then
        MsgBox "No range selected. Operation canceled.", vbExclamation
        Exit Sub
    End If
    ' Ask for optional password
    pwd = InputBox("Enter a password to protect the sheet (leave empty for none):", _
                   "Password Protection")
    ' Unlock all cells first
    ws.Cells.Locked = False
    ' Lock the chosen range
    rng.Locked = True
    ' Protect worksheet with or without password
    If pwd <> "" Then
        ws.Protect Password:=pwd, UserInterfaceOnly:=True
        MsgBox "Cells locked and sheet protected with a password.", vbInformation
    Else
        ws.Protect UserInterfaceOnly:=True
        MsgBox "Cells locked and sheet protected without a password.", vbInformation
    End If
End Sub

➤ Press  F5  or click on the Run tab >> Run Sub/UserForm.

Use VBA to Lock Cells

➤ As Excel opens the Lock Cells dialog box, go back to the Excel tab and click on the upside arrow to select the cells or ranges you want to lock. You can press and hold the  Ctrl  key to select non-adjacent cells or ranges. Press Ok.

Use VBA to Lock Cells

➤ Enter a password (optional) or leave the field empty. Click Ok.

Use VBA to Lock Cells

➤ All the cells you selected are now locked.


Frequently Asked Questions

How to unlock the locked cells in Excel?

If you want to make locked cells editable again, go to the Review tab >> Unprotect Sheet. Enter the correct password if needed. Select the cells you want to unlock, right-click on them, and choose Format Cells from the menu. Now, open the Protection tab, uncheck Locked, and click Ok.

How to lock cells in Excel but allow formatting?

Select your entire data range right-click, and choose Format Cells. In the Format Cells window, click on the Protection tab >> uncheck Locked >> click Ok. Now, choose the cells you want to lock, click on the Home tab >> Format drop-down >> Lock Cell. Click on the Format drop-down again and select Protect Sheet. In the Protect Sheet dialog box, check the Format Cells box and press Ok.

How to prevent deleting any sheets in Excel?

To prevent Excel sheets from deleting, you can use the Protect Workbook feature. For this, go to the Review tab and choose Protect Workbook. This prevents adding, deleting, hiding, or moving sheets, but does not protect cell contents inside sheets.


Concluding Words

With Excel’s protection and security features, you can protect or unprotect specific cells anytime in just a few clicks. To allow edit access to any user, you need to enter the correct password.

Keep in mind that Excel’s basic security features can be overwritten. So, avoid publicly sharing Excel files with sensitive information even if you’ve locked them from editing.

ExcelInsider Team
We will be happy to hear your thoughts

Leave a reply

Excel Insider
Logo