Yes, by default Excel has all cells set to be locked if the worksheet is
protected. Thats why I said you will have to unlock cells that users need to
type in. There is no way to lock cells without protected the worksheet.
My code will work for you with the criteria you asked for in your original
post. Now you have totally new criteria. This new code below will work with
the new criteria I think you gave.
To explain. This code will test if the Target is within B7:B1000. If it
is, the code will scan each cell in B7:B1000 testing if it is a date and if
it is less than B5. If the cell is less that B5 then the adjacent cells in
Col. G thru Col. J are locked else they are unlocked. For example, if B10 is
less than B5 then G10:J10 is locked. Note make sure that the cells you want
the user to type in are unlocked. I would suggest unlocking the whole sheet.
Thus only Cols. G thru Cols. J will be locked.
Hope this helps! If so, let me know, click "YES' below.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim MyRange As Range
Dim rng As Range
With Sheets("Biz FT Daily")
' test if Target is in Range B7:B1000
Set MyRange = Application.Intersect(.Range("B7:B1000"), Target)
' if Target is in range run loop
If Not MyRange Is Nothing Then
' unprotect sheet so locked property can be changed
.Unprotect
' scan each cell in range to test if it = 1
For Each rng In .Range("B7:B1000")
' test if rng value is a date
If IsDate(rng.Value) Then
' lock or unlock cells dependent on B5
If rng.Value < .Range("B5") Then
.Range(.Cells(rng.Row, "G"), .Cells(rng.Row,
"J")).Locked = True
Else
.Range(.Cells(rng.Row, "G"), .Cells(rng.Row,
"J")).Locked = False
End If
End If
Next rng
End If
' protect sheet so cells selected to be locked will lock
.Protect
End With
End Sub