Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Protect/unprotect a list of sheets via their codenames

Looking for sub to protect/unprotect a list of sheets via using their
codenames, eg:
Sheet8
Sheet97
etc

Thanks




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default Protect/unprotect a list of sheets via their codenames

After reading your post I assume you want to protect and unprotect a random
set of sheets. This code should work well for you. Just list the sheet
names in the With Statement to fit your application. Hope this helps! If
so, let me know, click "YES" below.

Sub ProtectSheets()

Dim colSheets As Collection
Dim wks As Worksheet

' build collection of sheets
Set colSheets = New Collection
With colSheets
.Add Sheets("Sheet8")
.Add Sheets("Sheet97")
End With

' protect worksheets in collection
For Each wks In colSheets
wks.Protect "Password Goes Here"
Next wks

End Sub


Sub UnProtectSheets()

Dim colSheets As Collection
Dim wks As Worksheet

' build collection of sheets
Set colSheets = New Collection
With colSheets
.Add Sheets("Sheet8")
.Add Sheets("Sheet97")
End With

' protect worksheets in collection
For Each wks In colSheets
wks.Unprotect "Password Goes Here"
Next wks

End Sub

If
--
Cheers,
Ryan


"Max" wrote:

Looking for sub to protect/unprotect a list of sheets via using their
codenames, eg:
Sheet8
Sheet97
etc

Thanks




  #3   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Protect/unprotect a list of sheets via their codenames

Thanks, Ryan. I tweaked it a bit to refer to the actual codenames (below) and
it worked v.well. Marvellous!

.Add Sheet8
.Add Sheet97

Reply
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/unprotect all sheets at once? wx4usa New Users to Excel 4 July 22nd 08 12:08 AM
Protect-Unprotect all the sheets Gary Excel Worksheet Functions 7 February 26th 07 08:13 PM
protect/unprotect all sheets roos Excel Programming 4 January 13th 06 10:49 PM
Protect / Unprotect Sheets Rob F[_2_] Excel Programming 3 August 10th 04 02:27 PM
Protect/Unprotect Sheets Deeds[_2_] Excel Programming 1 May 27th 04 08:43 PM


All times are GMT +1. The time now is 06:42 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"