Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Looking for sub to protect/unprotect a list of sheets via using their
codenames, eg: Sheet8 Sheet97 etc Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Protect/unprotect all sheets at once? | New Users to Excel | |||
Protect-Unprotect all the sheets | Excel Worksheet Functions | |||
protect/unprotect all sheets | Excel Programming | |||
Protect / Unprotect Sheets | Excel Programming | |||
Protect/Unprotect Sheets | Excel Programming |