multiple sheet unprotect

jammoca

Banned
Joined
Nov 6, 2002
Messages
1,100
Is there a way to protect or unprotect multiple sheets at a time.

Currently, I have a wokbook that can have up to 60 sheets and occasionally I might need to unprotect all sheets to make amendments to cells that are protectd.

Unprotecting one sheet at a time is a pain in the rear

Any clues ?
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
L

Legacy 51064

Guest
The download is nice, but if you have to send the document to someone with out it...

I created a use form with a Text box and Enter button on it. Right click on the User Form in the project viewer and add this code to it:
Code:
Private Sub CommandButton1_Click()

'Deactivates the alerts and screen updates
    Application.DisplayAlerts = False
    Application.ScreenUpdating = False

On Error GoTo ERR
Dim wSheet As Worksheet
   For Each wSheet In Worksheets
      If wSheet.ProtectContents = True Then
         wSheet.Unprotect Password:=TextBox1.Text
      Else
         wSheet.Protect Password:=TextBox1.Text
      End If
   Next wSheet
Unload Me
Exit Sub

ERR:
resp = MsgBox("You Entered the wrong password")
Unload Me

End Sub

I then added a module button to run the macro and added this code to run:
Code:
Sub Password()
    UserForm1.Show
End Sub
 
Upvote 0

ROLSON666

New Member
Joined
Aug 7, 2007
Messages
23
protecting multiple sheets at once

the asap utility worked fine....now I would like to know if protecting multiple sheets can be done on multiple files/workbooks at the same time.????
 
Upvote 0

dave3009

Well-known Member
Joined
Jun 23, 2006
Messages
7,128
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
  2. Mobile
  3. Web
Hi There

Try this

Code:
Sub Unprotect()

Dim ws As Worksheet
Dim wb As Workbook
Set wb = ActiveWorkbook
For Each ws In wb.Worksheets
  ws.Protect 
Next ws

End Sub
 
Upvote 0

Forum statistics

Threads
1,191,073
Messages
5,984,465
Members
439,890
Latest member
ALDBNL

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