Macro for Unlocking Multiple Worksheets

G

Guest

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
 
D

Dave Peterson

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!)
 
G

Guest

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
 
D

Dave Peterson

Yep. Except this is VBA, not VBScript.

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

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

Top