Using code and apply to other spreadsheet?

bsnapool

Active Member
Joined
Jul 10, 2006
Messages
452
I have the following code which meets my requirments for individual spreadsheets....


Code:
Sub Unprotect52() 
Dim ws As Worksheet 

    For I = 1 To 52 
        Set ws = Worksheets(CStr(I)) 
        With ws 
            .Unprotect "liverpool" 
            .Cells.ClearContents 
            .Protect "liverpool" 
            .Tab.ColorIndex = -4142 
        End With 
    Next I 

End Sub

I have 75 spreadsheets which are the same, in the same directory/folder. Is there any way I could run this code and this would run on all 75 spreadsheets?

Note, 75 spreadsheets have passwords on them, but I have a full list of team names and passwords.

Any help would be much appreciated.

Thanks

Andrew
 
I think this is corect... Im sure you will tell me otherwsie... When I corrected the below code to FALSE

Code:
'if filename/password was found, code continues here 

            'open the workbook, sets to variable Bk 
            Set Bk = Workbooks.Open(Filename:=.FoundFiles(i), _ 
            ReadOnly:=True, Password:=sPassword)

?
 
Upvote 0

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hit the jackpot!!! Kristy you are a legend...

My previous post stated that I made one slight amendment to the code read only: TRUE. I changed to FALSE.

Code:
'if filename/password was found, code continues here 

            'open the workbook, sets to variable Bk 
            Set Bk = Workbooks.Open(Filename:=.FoundFiles(i), _ 
            ReadOnly:=True, Password:=sPassword)

Kristy, thanks once again, although I will use this code once a year, This will save me 2 whole days work.


Andrew
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,262
Members
449,075
Latest member
staticfluids

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