Removing worksheet protection from multiple workbooks

caman06

New Member
Joined
Aug 12, 2015
Messages
14
Hi Everyone,

Im hoping someone may be able to help me out.

I have a large selection of excel files within folders that I need to process.

Some files have protected worksheets and some don't

I have the password required but Im trying to find a way that I can get a macro to go through all the excel workbooks within a folder and sub folders, check if it has protected worksheets (of which there may be one or many), then unprotect all the worksheets, save the work book and close it then move on to the next.

The script I am using to unprotect all the worksheets is:

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

any help would be greatly received thank you
 

mumps

Well-known Member
Joined
Apr 11, 2012
Messages
8,506
Is the password the same for all the worksheets in all the files?
 

caman06

New Member
Joined
Aug 12, 2015
Messages
14
Yes it's the same password used to protect any of the sheets in all the files. It's just only about half of them have any protected worksheets in.
 

mumps

Well-known Member
Joined
Apr 11, 2012
Messages
8,506
What is the full path to the folder containing the files and sub folders? Do the files all have the same extension (xls, xlsx, xlsm)?
 

Forum statistics

Threads
1,081,680
Messages
5,360,506
Members
400,589
Latest member
Mikealphatangoc

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top