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
Default Locking/Unlocking sheets using a range.


Currently I'm administrating a large spreadsheet. I've built in an
administrative page so I can quickly unlock and modify the workbook as
needed. However, I'm always interested in making my coding more
efficient.

This is an example of something I think might be fixable:

Private Sub Lockall()
PW = Range("C2").Value
Application.ScreenUpdating = False
ActiveWorkbook.Protect (PW)
Worksheets("Site 1").Protect (PW)
Worksheets("Overview").Protect (PW)
Worksheets("Site 2").Protect (PW)
Worksheets("Site 3").Protect (PW)
Worksheets("Site 4").Protect (PW)
Worksheets("Site 5").Protect (PW)
Worksheets("Site 6").Protect (PW)
Worksheets("Site 7").Protect (PW)
........(Truncated).....
Range("C4").Value = "Locked"
Application.ScreenUpdating = True
End Sub

Such programming becomes tiresome when I add new sheets into the
workbook because I have to modify the protect/unprotect hide/unhide
codes.

Is there a way that I can simplify it using a range? I'd think it
would look something like this, but all my attempts have been met with
errors.

Private Sub Lockall()
PW = Range("C2").Value
Application.ScreenUpdating = False
ActiveWorkbook.Protect (PW)
Worksheets(range("A1":"A25")).Protect (PW)
Range("C4").Value = "Locked"
Application.ScreenUpdating = True
End Sub


--
wilro85
------------------------------------------------------------------------
wilro85's Profile: http://www.excelforum.com/member.php...o&userid=26935
View this thread: http://www.excelforum.com/showthread...hreadid=572449

 
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
locking and unlocking worksheets adam Excel Worksheet Functions 6 October 31st 07 05:31 PM
Conditional Cell Locking/Unlocking deelee[_2_] Excel Programming 5 May 27th 06 11:31 PM
Unlocking and locking a specific cell Reggie Excel Programming 2 December 22nd 05 12:39 AM
Locking and unlocking a workbook Nigel Bennett Excel Programming 1 June 21st 04 03:58 PM
Locking/unlocking cells Ian Coates Excel Programming 1 February 3rd 04 04:04 PM


All times are GMT +1. The time now is 08:48 AM.

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"