LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Protect sheets

Greetings and TIA for your time
I am using the code below to protect selected worksheets so that the user
can only select unlocked cells and can enter comments (in unlocked cells)

Running the code below has the desired effect. However, when I save the
file, close and re-open, the protection is still in place but the user can
now also select locked cells. How do I prevent the user selecting locked
cells after save, close and re-open?

Sub ProtectSelectedSheets()
Dim wks As Worksheet
Dim myarray()
ReDim myarray(1 To ActiveWindow.SelectedSheets.Count)
counter = 0
For Each wks In ActiveWindow.SelectedSheets
counter = counter + 1
myarray(counter) = wks.Name
Next
For i = 1 To counter
With Worksheets(myarray(i))
.EnableSelection = xlUnlockedCells
.Protect Password:="pwd", DrawingObjects:=False, _
Contents:=True, Scenarios:=True, userinterfaceonly:=True
End With
Next
End Sub
--
David
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Protect sheets in one go mohavv Excel Discussion (Misc queries) 4 March 11th 08 10:21 PM
Protect some sheets in an xls but not all. lucky1 Excel Worksheet Functions 0 June 6th 07 09:05 PM
Protect all Sheets Phil Osman Excel Discussion (Misc queries) 0 June 17th 05 01:55 AM
how to protect sheets from VBA? jon Excel Programming 1 September 16th 04 06:11 PM
Protect a few sheets Soniya Excel Programming 0 August 27th 03 08:11 AM


All times are GMT +1. The time now is 12:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"