protect sheet

tokhimi

Board Regular
Joined
Jul 10, 2010
Messages
61
Hi all help me on macro protection sheets

When im using macro protection sheets with password , but when im press on tool > protection > then unprotect but no need password then will unprotect .???


help.//
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
To protect a sheet with a password try code like this

Code:
ActiveSheet.Protect Password:="your password here"
 

tokhimi

Board Regular
Joined
Jul 10, 2010
Messages
61
Sub SetPrintArea()
Sheet2.Unprotect Password:="2287"
'Sets Print Area and prints
ActiveWindow.SelectedSheets("Print Screen").Visible = xlSheetVisible
Sheets("Print Screen").Select
Selection.AutoFilter Field:=1, Criteria1:="<>", Operator:=xlAnd
Dim LstRw As Long
Dim ws As Worksheet
Set ws = Sheets("Print Screen")
With ws
LstRw = .Cells(Rows.Count, "A").End(xlUp).Row
End With
Columns("$A:$H").Select
With ActiveSheet.PageSetup
.FitToPagesWide = 1
ActiveSheet.PageSetup.PrintArea = "A1:H1" & LstRw
End With
Selection.PrintOut Copies:=1, Preview:=True, Collate:=True
MsgBox "See you again @"
Sheet2.Unprotect Password:="PASWORD"
ActiveWindow.SelectedSheets("Print Screen").Visible = xlSheetVisible
Sheets("Print Screen").Select
Selection.AutoFilter Field:=1
ActiveSheet.Protect Password:="PASWORD"
Sheet2.EnableAutoFilter = True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True
End Sub



HI Vog not working

When im press tools > protection > unprotect then ,all release with no need password .
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
That code is confusing to say the least.

First you are unprotecting Sheet2 with the password 2287

Then you are unprotecting it again with the password PASWORD

Then you are protecting Print Screen with the password PASWORD
 

tokhimi

Board Regular
Joined
Jul 10, 2010
Messages
61

ADVERTISEMENT

Hi Vog

If all password change to "password" also same

becouse the point is the password is using macro to protect ,but when im normal go to tools > protection > unprotect ,,then will release the protect no need to key password
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try this

Code:
Sub test()
Sheets.Add
ActiveSheet.Protect Password:="password"
End Sub

Can you unprotect the new sheet manually without a password? I cannot.
 

tokhimi

Board Regular
Joined
Jul 10, 2010
Messages
61

ADVERTISEMENT

Hi Vog

i find out already

when i try out with what u post is ok cannot unprotect without password

but u try add this at below

Sheet2.EnableAutoFilter = True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True

then will release without password
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Because you haven't supplied a password!

Rich (BB code):
ActiveSheet.Protect Password:="PASWORD", DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True
 

tokhimi

Board Regular
Joined
Jul 10, 2010
Messages
61
" password" if i change to my password also not use;;

hi vog u try to put

Sheet2.EnableAutoFilter = True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True


on thaT U sent me test 1 u will know what im saying //with
Sheet2.EnableAutoFilter = True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True
and without this different tools > protect > unprotect
 

tokhimi

Board Regular
Joined
Jul 10, 2010
Messages
61
When im using macro protection sheets with password
when im press on tool > protection > then unprotect
then no need password then will unprotect .???


Sub test()
Sheets.Add
ActiveSheet.Protect Password:="123"
Sheet2.EnableAutoFilter = True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True

End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,523
Messages
5,837,845
Members
430,518
Latest member
smithk901

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