Pass word protecting multipul worksheets within a workbook

  • Thread starter Thread starter Terrie
  • Start date Start date
T

Terrie

is there a way to pass word protect multiful worksheets within a workbook at
the same time.

i have several workbooks that have 5-35 worksheets that all need pass word
protected and would like to do it all at the same time.
 
This will do it

Sub Macro1()
Dim strPassword As String
Dim mySheet As Worksheet
For Each mySheet In Worksheets
strPassword = InputBox("Enter the password for the worksheet")
mySheet.Protect Password:=strPassword, Scenarios:=True
Next
End Sub

If you wish to use a single password
Sub Macro1()
Dim strPassword As String
Dim mySheet As Worksheet
strPassword = InputBox("Enter the password for the worksheet")
For Each mySheet In Worksheets
mySheet.Protect Password:=strPassword, Scenarios:=True
Next
End Sub

Need hep with VBA? David McRitchie's site on "getting started" with VBA
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Happy New Year
 
Back
Top