ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Password and Macro (https://www.excelbanter.com/excel-discussion-misc-queries/151444-password-macro.html)

Wanna Learn

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

Mike H

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


Wanna Learn

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


Mike H

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


Wanna Learn

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



All times are GMT +1. The time now is 05:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com