MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Locking Cells to Protect Critical Data

October 12, 2001 - by Bill Jelen

Frank from Holland posed today's question:

Hello, I want to make a sort of database in Excel. Therefore, I need to find a Macro or something like that, with which I can create a command that makes the cursor jump from (for example) A16 to B2 after using the enter-button on A16. Would you know the solution for this problem? Thanks!

One easy way to achieve this is to make A16 and B2 the only unlocked cells on the worksheet. By default, all cells are locked. You can use Format - Cells - Protection - uncheck the Locked checkbox to unlock the cells.

In Excel 2000 and earlier you can simply protect the worksheet with Tools - Protection - Protect Sheet. In Excel 2002 you will have to use Tools - Protection - Protect Sheet and then uncheck the option for "Select locked cells".

After the sheet is successfully protected, hitting enter in one unprotected cell will take you to the next unprotected cell.


If protecting the worksheet is not practical, you would have to resort to a Worksheet_Change macro that sensed which cell just changed.

Here is a sample macro:

Private Sub Worksheet_Change(ByVal Target As Range)
    Select Case Target.Address
        Case "$B$2"
        Case "$A$16"
    End Select
End Sub