ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Macro for Unlocking Multiple Worksheets (https://www.excelbanter.com/excel-worksheet-functions/156312-macro-unlocking-multiple-worksheets.html)

Storm

Macro for Unlocking Multiple Worksheets
 
Hello.

I have a file that has multiple worksheets, each are protected (locked) with
a similar password for each worksheet. Is there a way to unprotect all
worksheets all at once without having to click on each sheet and unprotect it
that way? Is there a Macro? Or something?

Thank you!
Storm

Dave Peterson

Macro for Unlocking Multiple Worksheets
 
Option Explicit
sub testme()
dim myPWD as string
dim wks as worksheet
myPWD = "hi"
for each wks in activeworkbook.worksheets
wks.unprotect password:=mypwd
next wks
end sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm



(Untested, uncompiled--watch for typos!)

Storm wrote:

Hello.

I have a file that has multiple worksheets, each are protected (locked) with
a similar password for each worksheet. Is there a way to unprotect all
worksheets all at once without having to click on each sheet and unprotect it
that way? Is there a Macro? Or something?

Thank you!
Storm


--

Dave Peterson

Storm

Macro for Unlocking Multiple Worksheets
 
Hi Dave,

I just about gave up...thought no one would respond.

Yes, unfortunately, I am not that adept with creating macros thru VB script.
I will read up on the reference you indicated. Thank you.

For the mean time, do I simply copy paste your script below on the VB Script
editor and just replace the "hi" with my actual password?

Thanks again,
Storm

"Dave Peterson" wrote:

Option Explicit
sub testme()
dim myPWD as string
dim wks as worksheet
myPWD = "hi"
for each wks in activeworkbook.worksheets
wks.unprotect password:=mypwd
next wks
end sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm



(Untested, uncompiled--watch for typos!)

Storm wrote:

Hello.

I have a file that has multiple worksheets, each are protected (locked) with
a similar password for each worksheet. Is there a way to unprotect all
worksheets all at once without having to click on each sheet and unprotect it
that way? Is there a Macro? Or something?

Thank you!
Storm


--

Dave Peterson


Dave Peterson

Macro for Unlocking Multiple Worksheets
 
Yep. Except this is VBA, not VBScript.

Take a look at David McRitchie's site. You'll find details there.

Storm wrote:

Hi Dave,

I just about gave up...thought no one would respond.

Yes, unfortunately, I am not that adept with creating macros thru VB script.
I will read up on the reference you indicated. Thank you.

For the mean time, do I simply copy paste your script below on the VB Script
editor and just replace the "hi" with my actual password?

Thanks again,
Storm

"Dave Peterson" wrote:

Option Explicit
sub testme()
dim myPWD as string
dim wks as worksheet
myPWD = "hi"
for each wks in activeworkbook.worksheets
wks.unprotect password:=mypwd
next wks
end sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm



(Untested, uncompiled--watch for typos!)

Storm wrote:

Hello.

I have a file that has multiple worksheets, each are protected (locked) with
a similar password for each worksheet. Is there a way to unprotect all
worksheets all at once without having to click on each sheet and unprotect it
that way? Is there a Macro? Or something?

Thank you!
Storm


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 10:09 AM.

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