View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Protection macro


You might consider protecting the sheets using the UserInterfaceOnly
parameter. This prevents the user from modifying the worksheet but
allows VBA to do anything it wants, regardless of protection. This
property does not stick with the worksheet when the file is closed, so
you should use something like the following, in the ThisWorkbook
module:

Private Sub Workbook_Open()
Dim WS As Worksheet
For Each WS In ThisWorkbook.Worksheets
WS.Protect UserInterfaceOnly:=True
Next WS
End Sub

This will protect all the sheets from user modification but will allow
your VBA code to run without protection problems.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




On Thu, 23 Oct 2008 10:26:09 -0700, Neil Pearce
wrote:

Is there a macro that will automatically unprotect all worksheets when any
other marco is run?

More porblematic one would assume is a macro that automatically protects all
worksheets when another macro ends?