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?
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:
- Open Microsoft Excel then press [Alt+F11] to show Visual Basic Editor window.
- In [Insert] menu, select [Module] to create a module. Then write the following script:
Dim cll As Object
For Each cll In Selection
If cll.Locked = True Then
cll.Interior.ColorIndex = 9
If Selection.Locked = False Then
MsgBox "There is no locked cell in range that you choose", vbOKOnly, "Locked Cell Checker"
- 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
- 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].
- On Assign Macro dialog box, choose [ColLockCell] macro then click [OK].
Test the macro
- Select all cells in one worksheet by pressing [Ctrl+A].
- On Home tab Cells category, disable the [Locked Cell]toggle button. With this steps, all cells are unlocked.
- Now select cells from B2 to D9 then on the Home tab Cells category, enable the [Locked Cell] toggle button.
- Select cells from A1 to E10 then click [Locked Cell Checker]button. Cells from B1 to D9 will colored red.
- Then select unlocked cells, from example from F1 to H10 then click [Locked Cell Checker] button.
The Locked Cell Checker message box will displayed.