View Single Post
  #1   Report Post  
Dennis
 
Posts: n/a
Default Difference between Activesheet.unprotect

Using XL 2003


Can someone explain the differences between:

(A) ActiveSheet.Protect UserInterfaceOnly:=True
vs.
(B) ActiveSheet.Unprotect

In most cases where I have protected sheets, I can use (A) with no problems.

When attempting to use a macro to first delete then re-establish data
validation with different parameters (in a selected Range), I ran into a type
of " lost contact with X or Y error".

If I manually unprotected the sheet then ran the macro all was OK.

What I found was

Test Sub1()
ActiveSheet.Unprotect

..
.. "Data validation via VBA code"
..
..
..
..

ActiveSheet.Protect ' works
End Sub


Test Sub2()
ActiveSheet.Protect UserInterfaceOnly:=True
..
..
.. "Data validation via VBA code"
..
..
.. ' did not always work as mostly received
' error message mentioned above
End Sub

Any thoughts as to why?

Dennis