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.//
 

Some videos you may like

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

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
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,895
Messages
5,514,022
Members
408,982
Latest member
Cooksey19

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...
Top