Coloring Locked Cells in Microsoft Excel

Article translations Article translations
Article ID: 2829791 - View products that this article applies to.

About Author:

Collapse this tableExpand this table
Collapse this imageExpand this image
MVP
This article is provided by MVP Raddini Rahayu. Microsoft is so thankful that MVPs who proactively share their professional experience with other users. The article would be posted on MVP's website or blog later.
Expand all | Collapse all

On This Page

Overview

In Excel, we know that there are several layers of protection and the lowest point is by locking cells. By default, all of cells in a workbook is in locked mode. You can set any cell that is locked. For Example, if you want to protect the cells that contain formula, first you have to unlock all cells then selecting the cell that contain formula and lock it. When you have completed, you cannot see the difference between both of them in Microsoft Excel window. So how can we see the difference?

Resolution

To find out which cells are locked, we should give a mark. To do that we have to create a VBA Macro and in this case I will give a red color mark.

What to do

Here the steps to create the coloring locked cells Macro:

  1. Open Microsoft Excel then press [Alt+F11] to show Visual Basic Editor window.
  2. In [Insert] menu, select [Module] to create a module. Then write the following script:
    Sub ColLockCell()
    Dim cll As Object
    For Each cll In Selection
        If cll.Locked = True Then
        cll.Interior.ColorIndex = 9
    End If
    Next cll
    If Selection.Locked = False Then
    MsgBox "There is no locked cell in range that you choose", vbOKOnly, "Locked Cell Checker"
    End If
    End Sub
              
    Collapse this imageExpand this image
    2829846


  3. Close VBE window and back to Excel.

How it works

To know how this macro works, please note the following example:

Create locked cell checker

  1. On [Insert] tab Illustrations category, select [Shapes] and create one of them.
    Add text "Locked Cell Checker" then right click on it and select [Assign Macro].
  2. On Assign Macro dialog box, choose [ColLockCell] macro then click [OK].

    Collapse this imageExpand this image
    2829847

Test the macro

  1. Select all cells in one worksheet by pressing [Ctrl+A].
  2. On Home tab Cells category, disable the [Locked Cell]toggle button. With this steps, all cells are unlocked.
  3. Now select cells from B2 to D9 then on the Home tab Cells category, enable the [Locked Cell] toggle button.
  4. Select cells from A1 to E10 then click [Locked Cell Checker]button. Cells from B1 to D9 will colored red.

    Collapse this imageExpand this image
    2829848

  5. Then select unlocked cells, from example from F1 to H10 then click [Locked Cell Checker] button.
    The Locked Cell Checker message box will displayed.

    Collapse this imageExpand this image
    2829849


Community Solutions Content Disclaimer

MICROSOFT CORPORATION AND/OR ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY, RELIABILITY, OR ACCURACY OF THE INFORMATION AND RELATED GRAPHICS CONTAINED HEREIN. ALL SUCH INFORMATION AND RELATED GRAPHICS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT AND/OR ITS RESPECTIVE SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THIS INFORMATION AND RELATED GRAPHICS, INCLUDING ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, WORKMANLIKE EFFORT, TITLE AND NON-INFRINGEMENT. YOU SPECIFICALLY AGREE THAT IN NO EVENT SHALL MICROSOFT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, PUNITIVE, INCIDENTAL, SPECIAL, CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF USE, DATA OR PROFITS, ARISING OUT OF OR IN ANY WAY CONNECTED WITH THE USE OF OR INABILITY TO USE THE INFORMATION AND RELATED GRAPHICS CONTAINED HEREIN, WHETHER BASED ON CONTRACT, TORT, NEGLIGENCE, STRICT LIABILITY OR OTHERWISE, EVEN IF MICROSOFT OR ANY OF ITS SUPPLIERS HAS BEEN ADVISED OF THE POSSIBILITY OF DAMAGES.

Properties

Article ID: 2829791 - Last Review: September 25, 2013 - Revision: 6.1
Applies to
  • Microsoft Office Excel 2003
  • Microsoft Office Excel 2007
  • Microsoft Excel 2010
  • Microsoft Excel 2013
Keywords: 
kbstepbystep kbmvp kbcommunity KB2829791

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com