View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
STEVE BELL STEVE BELL is offline
external usenet poster
 
Posts: 692
Default Macro and Protected Sheet Problem

Daniel,

There is an alternative - check out the below code...
=======================================
Select UnProtected Cells ONLY
This will prevent users from clicking on protected cells on all
worksheets. Therefore, the warning message will not appear. The code
must be enterred in the ThisWorkbook module.

Note that the EnableSelection property must be reset each time the
workbook is opened as it defaults to xlNoRestrictions. The
worksheet(s)
must first be unprotected to set the EnableSelection property and then
must be protected for it to take effect.

Private Sub Workbook_Open()
Dim WS As Worksheet
For Each WS In ThisWorkbook.Worksheets
WS.Unprotect 'Password:="wxyz"
WS.EnableSelection = xlUnlockedCells
WS.Protect 'Password:="wxyz", UserInterfaceOnly:=True
Next
End Sub

Regards,
Greg Wilson 5/3/03


--
steveB

Remove "AYN" from email to respond
"Otto Moehrbach" wrote in message
...
In your macro, unprotect the sheet, hide the rows, protect the sheet.
HTH Otto
"Daniel R. Young" wrote in
message ...
I have macros that hide rows and I want to protect my sheet so individuals
will not be able to change any of the information. When the sheet is
protected the macro will not work. It goes to a debuger.

Is there a way to run my macros even though the sheet is protected?

Thank you,

Daniel