ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Protecting Multiple Sheets (https://www.excelbanter.com/excel-discussion-misc-queries/153445-protecting-multiple-sheets.html)

Susan

Protecting Multiple Sheets
 
I entered the following code

Sub ProtectAll()

Dim wSheet As Worksheet
Dim Pwd As String

Pwd = InputBox("Enter your password to protect all worksheets",
"Password Input")
For Each wSheet In Worksheets
wSheet.Protect Password:=Pwd
Next wSheet

End Sub




But when i run the code i get an error and all it says is "400", can someone
hep me, i am trying to protect 52 sheets at one time

Thanks

John Bundy

Protecting Multiple Sheets
 
I copy and pasted your exact code and it works, even tried with 100 sheets.
Where are you putting your code and what version?
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"SUSAN" wrote:

I entered the following code

Sub ProtectAll()

Dim wSheet As Worksheet
Dim Pwd As String

Pwd = InputBox("Enter your password to protect all worksheets",
"Password Input")
For Each wSheet In Worksheets
wSheet.Protect Password:=Pwd
Next wSheet

End Sub




But when i run the code i get an error and all it says is "400", can someone
hep me, i am trying to protect 52 sheets at one time

Thanks


Susan

Protecting Multiple Sheets
 
I am right clicking on the worksheet tab and clicking on view code and then
entering the code, then go to the worksheet and click on macors and run the
macro using version 2003, am i putting it in the wrong area?

"John Bundy" wrote:

I copy and pasted your exact code and it works, even tried with 100 sheets.
Where are you putting your code and what version?
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"SUSAN" wrote:

I entered the following code

Sub ProtectAll()

Dim wSheet As Worksheet
Dim Pwd As String

Pwd = InputBox("Enter your password to protect all worksheets",
"Password Input")
For Each wSheet In Worksheets
wSheet.Protect Password:=Pwd
Next wSheet

End Sub




But when i run the code i get an error and all it says is "400", can someone
hep me, i am trying to protect 52 sheets at one time

Thanks


Peo Sjoblom

Protecting Multiple Sheets
 
Yes you are, you should put it in a regular module, press alt + F11, select
the file in the project pane to the left and select insert module, that's
where to put it Then you run the macro from
Alt + F8 or attach it to a button or a menu



--
Regards,

Peo Sjoblom


"SUSAN" wrote in message
...
I am right clicking on the worksheet tab and clicking on view code and then
entering the code, then go to the worksheet and click on macors and run
the
macro using version 2003, am i putting it in the wrong area?

"John Bundy" wrote:

I copy and pasted your exact code and it works, even tried with 100
sheets.
Where are you putting your code and what version?
--
-John
Please rate when your question is answered to help us and others know
what
is helpful.


"SUSAN" wrote:

I entered the following code

Sub ProtectAll()

Dim wSheet As Worksheet
Dim Pwd As String

Pwd = InputBox("Enter your password to protect all worksheets",
"Password Input")
For Each wSheet In Worksheets
wSheet.Protect Password:=Pwd
Next wSheet

End Sub




But when i run the code i get an error and all it says is "400", can
someone
hep me, i am trying to protect 52 sheets at one time

Thanks





All times are GMT +1. The time now is 08:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com