using merged cells makes this more complicated. Try this code in the WorkBook_Open event. Note you must first of all unlock all cells in that range - Format -> Cells -> Protection and de-select Locked
Option Explicit
Private Sub Workbook_Open()
Const PW As String = "secret"
Dim rBookings As Range
Dim cl As Range
Dim mArea As Range
With Sheets("Availability")
.Unprotect PW
Set rBookings = .Range(.Cells(7, 4), .Cells(7675, 10)).SpecialCells(xlCellTypeConstants)
For Each cl In rBookings
Set mArea = .Cells(cl.Row, 1).MergeArea
If mArea.Cells(1, 1).Value <= Date Then cl.Locked = True
Next cl
.Protect PW
End With
End Sub
Copy the code
Select the workbook in which you want to use the code
Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
In the Project Explorer, find your workbook, and open the list of Microsoft Excel Objects
Right-click on the ThisWorkbook object, and choose View Code
Where the cursor is flashing, choose Edit | Paste
Bookmarks