Thread: Protected cells
View Single Post
  #3   Report Post  
Roy
 
Posts: n/a
Default

I don't think so to either question. I only have one file and eventhough I
do have macros in the workbook to unprotect and protect, I did not make them
run when the workbook is opened. I modified the macros that I found on this
site. Here are the macros I'm using:

Public Sub Unprotect_All()
Dim wks As Worksheet
Dim vPword As Variant
On Error Resume Next
For Each wks In ActiveWorkbook.Worksheets
With wks
.Unprotect vPword
Do While .ProtectContents
vPword = Application.InputBox( _
Prompt:="Enter password for " & .Name, _
Title:="Unprotect sheets", _
Default:="", _
Type:=2)
If vPword = False Then Exit Sub 'user cancelled
.Unprotect vPword
Loop
End With
Next
End Sub

Public Sub Protect_All()
Dim wks As Worksheet
Dim vPword As Variant
vPword = Application.InputBox( _
Prompt:="Enter Password: ", _
Title:="Protect sheets", _
Default:="", _
Type:=2)
If vPword = False Then Exit Sub 'user cancelled
For Each wks In ActiveWorkbook.Worksheets
wks.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
wks.EnableSelection = xlUnlockedCells
wks.Protect vPword
Next
End Sub



"Dave Peterson" wrote:

This isn't standard behavior.

Any chance you're opening the wrong workbook?

Or your workbook opens and a macro runs that does the unprotecting?

Roy wrote:

I have a sheet with protected cells. Everytime I re-open the file, the cells
become unprotected. How do I stop the cells from becoming unprotected?


--

Dave Peterson