Unprotecting Selected Sheets Only on Multiple Fil

stroffso

Board Regular
Joined
Jul 12, 2016
Messages
145
Hi,

I have 20 files to edit, all of which have a differing number of tabs protected (with the same password), What I want to do is select the protected tabs on each file manually, then run some code to unprotect, I then do what I need to do and protect again using similar code. Also to note that the tab names to protect and unprotect on each file are different

I have the below and have searched around but can only find protect or unprotect all routines. Would anyone be able to help here?


VBA Code:
Sub UnProtectAllSheets()
    Dim ws As Worksheet

    For Each ws In Worksheets
        ws.Unprotect "john12345"
    Next ws

End Sub
 
Last edited:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Jimmypop

Well-known Member
Joined
Sep 12, 2013
Messages
554
Office Version
  1. 365
Platform
  1. Windows
Maybe use a button or something to call the below module? You would need to select your sheets and run the following...

VBA Code:
Sub UnprotectSelected()
    Dim ws As Worksheet
    For Each ws In ActiveWindow.SelectedSheets
         ws.Unprotect "john12345"
    Next ws
End Sub
 

stroffso

Board Regular
Joined
Jul 12, 2016
Messages
145
Maybe use a button or something to call the below module? You would need to select your sheets and run the following...

VBA Code:
Sub UnprotectSelected()
    Dim ws As Worksheet
    For Each ws In ActiveWindow.SelectedSheets
         ws.Unprotect "john12345"
    Next ws
End Sub
Outstanding thank you that works great
 

Jimmypop

Well-known Member
Joined
Sep 12, 2013
Messages
554
Office Version
  1. 365
Platform
  1. Windows
Glad to be of assistance :cool:
 

Forum statistics

Threads
1,182,103
Messages
5,933,657
Members
436,904
Latest member
DangerKennedy

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
Top