Protect/unprotect ALL  worksheets in workbook ? in Excel General Questions  
 |  Edit my Profile  |  Help
 
     
  
 
 
 
Newsgal 3/29/2006 12:58 PM PST
  Question
 
-- Is it possible to protect/unprotect all worksheets in a workbook at once
instead of having to do each individually if the password is the same?

News Gal
 
  Was this post helpful to you?  
 
 
  Reply | Print post   TopTop  
 
 
 
 
Chip Pearson 3/29/2006 1:07 PM PST
  Answer
  The only way to do that is with some VBA code:

Sub ProtectAll()
Dim WS As Worksheet
For Each WS In ActiveWorkbook.Worksheets
WS.Protect Password:="whatever"
Next WS
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Newsgal" <Newsgal@discussions.microsoft.com> wrote in message
news:FB4ADCA0-F104-4135-A3AB-29DE05394507@microsoft.com...
>
> -- Is it possible to protect/unprotect all worksheets in a
> workbook at once
> instead of having to do each individually if the password is
> the same?
>
> News Gal


 
  Was this post helpful to you?  
 
 
  Reply | Print post   TopTop  
 
 
 
 
Kevin B 3/29/2006 1:08 PM PST
   
  This macro would do the trick

Sub Unprotect()

Dim wb As Workbook
Dim ws As Worksheet
Dim blnIsProtected As Boolean
Set wb = ActiveWorkbook

For Each ws In wb.Worksheets
ws.Unprotect "test"
Next ws

Set wb = Nothing
Set ws = Nothing

End Sub

--
Kevin Backmann


"Newsgal" wrote:

>
> -- Is it possible to protect/unprotect all worksheets in a workbook at once
> instead of having to do each individually if the password is the same?
>
> News Gal
 
  Was this post helpful to you?  
 
 
  Reply | Print post   TopTop  
 
 
 
 
Ron de Bruin 3/29/2006 1:09 PM PST
   
  The only way is to use a macro to do this

Sub test()
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
sh.Unprotect "ron"
Next sh
End Sub

Or
sh.Protect "ron"



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Newsgal" <Newsgal@discussions.microsoft.com> wrote in message news:FB4ADCA0-F104-4135-A3AB-29DE05394507@microsoft.com...
>
> -- Is it possible to protect/unprotect all worksheets in a workbook at once
> instead of having to do each individually if the password is the same?
>
> News Gal


 
  Was this post helpful to you?  
 
 
  Reply | Print post   TopTop  
 
 
  Return to Microsoft Communities  Notify me of replies