You are currently offline, waiting for your internet to reconnect

Coloring Locked Cells in Microsoft Excel

Support for Office 2003 has ended

Microsoft ended support for Office 2003 on April 8, 2014. This change has affected your software updates and security options. Learn what this means for you and how to stay protected.

About Author:

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.
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 ObjectFor Each cll In Selection    If cll.Locked = True Then    cll.Interior.ColorIndex = 9End IfNext cllIf Selection.Locked = False ThenMsgBox "There is no locked cell in range that you choose", vbOKOnly, "Locked Cell Checker"End IfEnd Sub          


  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].


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.


  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.



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: 09/23/2015 09:46:00 - Revision: 8.0

  • Microsoft Office Excel 2003
  • Microsoft Office Excel 2007
  • Microsoft Excel 2010
  • Microsoft Excel 2013
  • Excel 2016
  • kbstepbystep kbmvp kbcommunity KB2829791
Feedback