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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top