Locking Worksheet w/ password and conditions.

wmtsub

Active Member
Joined
Jun 20, 2018
Messages
322
How can I the password to apply automatically. This gives me an error.

Also can I set it so I can copy data form a specific column [e]or from the status bar?


ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFiltering:=True "password"
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
.

Here are two sets of macros. One to protect/unprotect all sheets ... One to protect/unprotect a single sheet :

Code:
Option Explicit


Sub ProtectAll()
'Updateby Extendoffice 20161215
Dim x As Long
Sheet1.Select
For x = 2 To ThisWorkbook.Sheets.Count
    If Sheets(x).Name <> "Sheet1" Then Sheets(x).Protect Password:="abc"
Next x
End Sub


Sub UnProtectAll()
'Updateby Extendoffice 20161215
Dim x As Long
Sheet1.Select
For x = 2 To ThisWorkbook.Sheets.Count
    If Sheets(x).Name <> "Sheet1" Then Sheets(x).Unprotect Password:="abc"
Next x
End Sub




Sub ProtectSheet()
    Sheet1.Protect Password:="abc"
    
End Sub


Sub UnprotectSheet()
    Sheet1.Unprotect Password:="abc"
End Sub
 
Upvote 0
Thanks, Can do that. What I was trying to ask for was to PW protect the 1 sheet W/ the conditions specified.
 
Upvote 0
Thanks but none of those address what I am asking for.

part 1] Why does this not work?
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFiltering:=True "password"

part 2] is it possible to COPY from the status bar of a locked sheet?
 
Upvote 0
.
This works :

Code:
Option Explicit


Sub shtprotect()
    ActiveSheet.Protect Password:="pw"
End Sub

The remainder of the line of code would most likely work if the sheet were unprotected first.

The same holds true for copying anything from that sheet. You can copy while the sheet is protected, but you can only paste to another sheet ...
unless the same sheet is first unprotected.
 
Upvote 0
The sheet is unlocked and this does not work, it does however if I remove rrthe PW.
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFiltering:=True Password="XX"
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

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