Loading
Excel.Tips.Net ExcelTips (Menu Interface)

Locking All Non-Empty Cells

Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Locking All Non-Empty Cells.

Sandeep has a worksheet that has hundreds of rows and columns. Some of the cells have information in them and some are empty. The empty cells are used for data entry. He would like a way to easily lock all the non-empty cells in a selected range and then lock the worksheet.

This is rather easy to do manually. There is an important item to keep in mind, however: All the cells in the worksheet are "locked," by default. In other words, you don't need to look for a way to lock the non-empty cells; you only need to look for a way to unlock the empty ones. (There is one exception to this, addressed shortly.)

With this in mind, you can follow these steps to get your empty cells unlocked:

  1. Select the range you want to affect.
  2. Press F5. Excel displays the Go To dialog box. (See Figure 1.)
  3. Figure 1. The Go To dialog box.

  4. Click Special. Excel displays the Go To Special dialog box. (See Figure 2.)
  5. Figure 2. The Go To Special dialog box.

  6. Select the Blanks radio button.
  7. Click OK.
  8. Press Ctrl+1. Excel displays the Format Cells dialog box.
  9. Make sure the Protection tab is selected. (See Figure 3.)
  10. Figure 3. The Protection tab of the Format Cells dialog box.

  11. Clear the Locked check box.
  12. Click OK.

That's it. You can now lock your worksheet and only those blank cells that were selected at the end of step 5 will be accessible.

One interesting thing to note is that you don't really have to select a range in step 1. If, instead, you select a cell within the main body of your worksheet's entries, Excel assumes that you want to operate on the used area of your worksheet. In other words, when you get to step 5 what will be selected are all the empty cells in the used area of you worksheet.

One more thing to be aware of is that once you set the locking status of a cell (step 8), the cell retains that status until you specifically change it. This means that if you've previously made changes to the locking status of the cells, it may be beneficial to explicitly lock the cells prior to unlocking the empty ones. You can do this by following these modified steps:

  1. Select the range you want to affect.
  2. Press Ctrl+1. Excel displays the Format Cells dialog box.
  3. Make sure the Protection tab is selected.
  4. Make sure the Locked check box is selected.
  5. Click OK.
  6. Press F5. Excel displays the Go To dialog box.
  7. Click Special. Excel displays the Go To Special dialog box.
  8. Select the Blanks radio button.
  9. Click OK.
  10. Press Ctrl+1. Excel displays the Format Cells dialog box.
  11. Make sure the Protection tab is selected.
  12. Clear the Locked check box.
  13. Click OK.

In this case you must perform step 1—you have to select a range to affect. Excel won't assume which range you want to affect as in the earlier comment.

If you prefer, you can use a macro to protect your cells and your worksheet:

Sub UnlockEmptyCells()
    Dim myCell As Range

    Set myCell = Selection
    Cells.Select
    Selection.Locked = True
    myCell.Select
    Selection.SpecialCells(xlCellTypeBlanks).Select
    Selection.Locked = False
    
    ActiveSheet.Protect DrawingObjects:=True, _
      Contents:=True, Scenarios:=True
    myCell.Select
End Sub

This macro makes sure that all the cells in the worksheet are locked, then it unlocks the blank cells in the used range, and finally it protects the worksheet.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (8483) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Locking All Non-Empty Cells.

Related Tips:

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

 

Leave your own comment:

*Name:
Email:
  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*Text:
*What is 5+3 (To prevent automated submissions and spam.)
 
 
           Commenting Terms

Comments for this tip:

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
 
 

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us

 

Advertise with Us

Our Privacy Policy

Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)

Gardening

Health

Home Improvement

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Our Products

Helpful E-books

Newsletter Archives

 

Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2016 Sharon Parq Associates, Inc.