I have a workbook with all months of the year. I am trying to lock certain cells within tables based on today's date. So essentially, if today's date is not the same month as listed in "A1", all cells remain locked. However if today is in the same month as "A1", I would like columns "Date Completed" & "Comments" unlocked. The table can shrink or expand so the solution must be dynamic. Also.....sheets are protected.
With the help of others on this site, I was able to created below code......but as you can see it is a mess:
Sub Workbook_SheetActivate(ByVal Sh As Object)
If DateSerial(Month(Range("A1").Value)) <> DateValue(Now) Then
ActiveSheet.Unprotect Password:="password"
ListObjects("Adv_Feb").ListColumns("Date Completed").Range.Locked = False
ListObjects("Adv_Feb").ListColumns("Comments").Range.Locked = False
ActiveSheet.Protect Password:="password"
End If
End Sub
Bookmarks