Code: Select all
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
With ws
.Visible = True
.Unprotect Password:=Password
.Protect Password:=Password, UserInterfaceOnly:=True
End With
Next
With Range("I_Tstart").Validation
.Delete
.Add Type:=xlValidateDate, AlertStyle:=xlValidAlertInformation, _
Operator:=xlBetween, Formula1:="1/Jan/" & Range("CurYear"), Formula2:="31/Dec/" & Range("CurYear")
If I run this code, the Validation.Delete works, but there is an error on the Validation.Add. However, if I comment out the ".Protect" statement above, all works fine.
I'm lost... There were other things I could explain. Could it be that my WB is somehow corrupt? Or am I not seeing something?