View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Wanna Learn Wanna Learn is offline
external usenet poster
 
Posts: 318
Default Password and Macro

Mike PERFECT ! thanks a million

"Mike H" wrote:

Hi

Delete the bits after activesheet.protect so the code looks more like

Sub protect()
Range("E2").Select
ActiveSheet.protect Password:="mypass"
Sheets("PG Report ").Select
ActiveSheet.protect Password:="mypass"
Sheets("Discount Grid").Select
Range("E2").Select
End Sub

"Wanna Learn" wrote:

Thanks Mike
Below is my code at the end of the macro, it seems I do not have a
password.... eventhough I had one when I recorded the macro)should I add your
code after "active sheet" in both places ?
Range("E2").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True,
AllowSorting _
:=True, AllowFiltering:=True
Sheets("PG Report ").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True
Sheets("Discount Grid").Select
Range("E2").Select

"Mike H" wrote:

Without seeing the code it's hard to say what's going wrong but a sheet
password protected with code should ask for a password to un-protect it.

Try this:-

Sub protect()
ActiveSheet.protect Password:="mypass"
End Sub

Mike

"Wanna Learn" wrote:

Hello I have a workbook with several spreadsheets. I created a macro to
format a workshheet, e.g. copy and paste special values and protect the
worksheet with a password then go to another worksheet and protect the
worksheet with a password and return to the original worksheet. WHen I run
the macro everything is fine except that when I unprotect the worksheet it
does not ask me for a password but it unprotects the worksheets anyway I
don't want anyone to be able to unprotect these worksheets without the
password. Help and Thanks