How to unlock cells only on certain date

Occasional Visitor


i need help if someone know how to lock or unlock specific cell soo users can write ther only in certains date. or if you know other program where to do it... 


3 Replies



Select cells you want to unlock. Right-click and select "format cells"



Go to Protection tab and unselect "Locked"





I believe you can do this process with a macro and have the macro run only on specific dates to unlock / lock cells.


This will take several steps.


Step 1: Unlock cells.

  • Select all the cells that users should be able to edit.
  • Press Ctrl+1 to activate the Format Cells dialog.
  • Activate the Protection tab.
  • Clear the Locked check box.
  • Click OK.

Step 2: Protect the worksheet.

  • Activate the Review tab of the ribbon.
  • Click Protect Sheet.
  • Use the check boxes to specify what users will be allowed to do.
  • Leave the Select Unlocked Cells checkbox ticked, otherwise users won't be able to edit any cells.
  • Enter a password in the Password box. Do not forget this password! It will be needed if you need to unlock the worksheet, and it will be needed in some VBA code too (see below).
  • Click OK.
  • You'll be asked to enter the password again as confirmation.
  • Click OK.

Step 3: VBA code.

  • Press Alt+F11 to activate the Visual Basic Editor.
  • In the Project Explorer pane on the left hand size, double-click ThisWorkbook under Microsoft Excel Objects.
  • Copy the code listed below into the ThisWorkbook module.
  • Change "Secret" to the password that you specified in Step 2.
  • Change "Sheet1" to the name of the sheet used in Step 1 and Step 2.
  • Change "C2" to the cell that you want to unlock on a specific date.
  • Change #5/12/2023# to the date on which you want to unlock the cell, in US date format m/d/yyyy.
  • Switch back to Excel.
  • Save the workbook as a macro-enabled workbook (*.xlsm).
  • Users will have to allow macros when they open the workbook.
  • This is the code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    With Worksheets("Sheet1")
        .Unprotect Password:="Secret"
        .Range("C2").Locked = True
        .Protect Password:="Secret"
    End With
End Sub

Private Sub Workbook_Open()
    With Worksheets("Sheet1")
        .Unprotect Password:="Secret"
        .Range("C2").Locked = (Date <> #3/6/2023#)
        .Protect Password:="Secret"
    End With
End Sub