Lock range if date < today
Try this snippet:
Sub DateLock()
Dim varDate As Date
Dim dif As Long
varDate = Range("A5")
If DateDiff("d", varDate, Date) 1 Then
Range("A5:I5").Locked = True
ActiveSheet.Protect
Else
Exit Sub
End If
End Sub
Mike F
"Kashyap" wrote in message
...
Hi I need to lock cells in protected and shared workbook if cell value in
colA is 2 days less than today
Eg. if A5=today()-2 then it should lock range A5:I5
|