View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Benito Merino Benito Merino is offline
external usenet poster
 
Posts: 8
Default Protecting multiple sheets

On 7 ene, 11:11, "Robert Crandal" wrote:
If my workbook has 20 sheets, I would like to write a script
that protects all 20 sheets at once, but it only asks the user
for a password once. *I basically want to display the same
dialog box that appears when someone presses the "Protect Sheet"
button.

Is this possible?


Hello.

One way is:


Sub protect()

For Each ws In ActiveWorkbook.Sheets
ws.protect Password:="pwsheet"
Next
End Sub


Sub unprotect()

For Each ws In ActiveWorkbook.Sheets
ws.unprotect Password:="pwsheet"
Next
End Sub

Regards,

Benito
Barcelona, spain