Protection Properties on WorkSheets

S

spences10

Hi, I have some code that I run on a lot of my workbooks which protects
all the worksheets with my password "PASS" the only thing is, is
that some of the properties of the protect function are not kept when
it is run. Specifically I want to have the sheet protected and only
want users to be able to 'Select unlocked cells' but it seems when
the code is run it enables users to 'Select locked cells' can
anyone help??

Function ProtectAll()

Application.ScreenUpdating = False
Dim Sh As Worksheet

For Each Sh In Worksheets
Sh.Visible = xlSheetVisible
Next

For Each Sh In Worksheets
Sh.Protect "PASS"
Next

For Each Sh In Worksheets
Sh.Select
With ActiveWindow
.DisplayHeadings = False
End With
Next

For Each Sh In Worksheets
Sh.Visible = xlHidden
Sheets("Cover").Visible = xlSheetVisible
Sheets("Cover").Select
Next

ActiveWorkbook.Protect "PASS"
Application.ScreenUpdating = True

End Function

Regards,

Scott Spence
 
S

spences10

ah ha!

thanks Chris 'Sh.EnableSelection = xlUnlockedCells '
was what i was after

thank you very much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top