Hello everyone,
It's my first post here, thank you for your time,.
I am building an excel sheet where users should not add any input into columns that do not match today's date, everyday.
For example, if today is 26 November, then user cannot add their initials for the column of 25 november or 27 or any other day than today. Tomorrow this will be 27 and so on.
I tried the following but something is not right:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim xRg As Range
Set xRg = Target.Worksheet.Cells(5, Target.Column)
If xRg <> Date Then
ActiveSheet.Protect Password:="111111"
MsgBox "Only today's date row can be edited!", vbInformation, "Kutools for Excel"
ElseIf xRg.Value = Date Then
ActiveSheet.Unprotect Password:="111111"
ActiveSheet.EnableSelection = xlNoRestrictions
End If
End Sub
I still can edit cells other than today's date.
Any clue what I am doing wrong?
Thank you!
Youssef
Bookmarks