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?
↑ Back to the top
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.
↑ Back to the top
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:
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
-
Close VBE window and back to Excel.
↑ Back to the top
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.
↑ Back to the top
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.
↑ Back to the top