#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 318
Default Password and Macro

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Password and Macro

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 318
Default Password and Macro

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

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Password and Macro

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

  #5   Report Post  
Posted to microsoft.public.excel.misc
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Password for Running the Macro Naveen Excel Discussion (Misc queries) 3 July 13th 07 03:08 PM
Macro & Password paulrm906 Excel Discussion (Misc queries) 2 March 4th 06 02:09 PM
Password hyperlink or macro? Jonah Excel Worksheet Functions 0 November 27th 05 06:38 PM
How to see macro code of a password protected macro without a password? Dmitry Kopnichev Excel Worksheet Functions 5 October 27th 05 09:57 AM
save as macro/for password Dedrie Excel Worksheet Functions 0 August 22nd 05 03:21 PM


All times are GMT +1. The time now is 03:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"