Unportect/Protect Multiple Workbooks

ChocksterNo1

New Member
Joined
Mar 22, 2011
Messages
24
Hi

I have a folder which contains another 8 folders and each folder has between 3 and 9 workbooks. Each workbook contains between 2 and 12 worksheets.

They all have the same password and every qtr I have to go in and edit these worksheets, which takes a long time to unprotect them and then reprotect them.

Is there a quick macro that I can apply to the one mast folder that would unprotect and then protect all the worksheets?

Thx

Chock
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
hi,

Try this (taken from here: http://www.excelforum.com/excel-pro...books-with-a-single-button-through-vba-2.html).

Basically, you create a seperate workbook called 'lists' and put in all your workbook names.

Code:
Sub testme()

    Dim myFileNames As String
    Dim myPasswords As String
    Dim myRealWkbkName As String
    Dim LastRowA1 As Long
    Dim LastRowB1 As Long
    Dim PWWorkbook As Workbook
    Dim i As Integer
    
    Application.ScreenUpdating = False
    
    myRealWkbkName = "C:\list.xls"
    'adjust as necessary
    
    Workbooks.Open myRealWkbkName, UpdateLinks:=False
    
    Set PWWorkbook = ActiveWorkbook
    
    LastRowA1 = PWWorkbook.Sheets("List").[A1].End(xlDown).Row
    LastRowB1 = PWWorkbook.Sheets("List").[B1].End(xlDown).Row
    
    If LastRowA1 <> LastRowB1 Then
        MsgBox "check names & passwords--qty mismatch!"
        Exit Sub
    End If
    
    For i = 1 To LastRowA1
    
        myFileNames = PWWorkbook.Sheets(1).Cells(i, 1).Value
        myPassword = "passwordhere"
        
        On Error Resume Next
        Workbooks.Open myFileNames, UpdateLinks:=False, Password:=myPassword
        On Error GoTo 0
    Next i
    
    Application.ScreenUpdating = True
    
End Sub

Then you can repeat the macro and add this: ActiveWorkbook.Protect password = myPassword
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,595
Messages
6,131,659
Members
449,662
Latest member
kismatta

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top