Red Smurf
09-03-2008, 04:51 AM
Hi,
I'm trying to lock cells in a range on a particular sheet depending on the contents of another range of cells. ie If column C contains dates, both historic and future, then if the date in column C is prior to todays date then the corresponding cell is column G needs to be locked regardless of whether it has anything in it or not. Can anyone help?
Below is what I've put together so far, locking the entire row rather than just the required cell, but unfortuanately it doesn't work:
Sub locking()
Dim c As Range
'Today's date is entered is cell D6
Set d = cell("D6").Value
For Each c In Range("C9", "C400").Select
If c < d Then
c.EntireRow.Locked = False
Else
c.EntireRow.Locked = True
End If
Next cell
End Sub
Could you tell me where I've gone wrong?
Many thanks,
I'm trying to lock cells in a range on a particular sheet depending on the contents of another range of cells. ie If column C contains dates, both historic and future, then if the date in column C is prior to todays date then the corresponding cell is column G needs to be locked regardless of whether it has anything in it or not. Can anyone help?
Below is what I've put together so far, locking the entire row rather than just the required cell, but unfortuanately it doesn't work:
Sub locking()
Dim c As Range
'Today's date is entered is cell D6
Set d = cell("D6").Value
For Each c In Range("C9", "C400").Select
If c < d Then
c.EntireRow.Locked = False
Else
c.EntireRow.Locked = True
End If
Next cell
End Sub
Could you tell me where I've gone wrong?
Many thanks,