ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Protect Worksheet (https://www.excelbanter.com/excel-programming/317997-protect-worksheet.html)

LennyG

Protect Worksheet
 
I wrote a macro to select certain options when reports on my worksheets are
being
printed. The sheets are then protected and when the macro is run, a message
appears stating that the commands could be accessed if the password is
entered (to remove the protection). How could I get the protection to
remain and get the macro to work.
Thanks
Lennox

Gord Dibben

Protect Worksheet
 
Lennox

If using Excel 2002 or 2003 you have the option when protecting the sheet of
allowing users to do certain operations on the sheet.

Earlier versions would require a macro to unprotect then re-protect the sheet.

ActiveSheet.Unprotect Password:="justme"

'do your stuff

ActiveSheet.Protect Password:="justme", DrawingObjects:=True, _
Contents:=True, Scenarios:=True

Gord Dibben Excel MVP

On Mon, 29 Nov 2004 17:47:05 -0800, LennyG
wrote:

I wrote a macro to select certain options when reports on my worksheets are
being
printed. The sheets are then protected and when the macro is run, a message
appears stating that the commands could be accessed if the password is
entered (to remove the protection). How could I get the protection to
remain and get the macro to work.
Thanks
Lennox



LennyG

Protect Worksheet
 
Hi Gord,
I tried the code which you suggested and it works. Thanks very much.
Lennox.

"Gord Dibben" wrote:

Lennox

If using Excel 2002 or 2003 you have the option when protecting the sheet of
allowing users to do certain operations on the sheet.

Earlier versions would require a macro to unprotect then re-protect the sheet.

ActiveSheet.Unprotect Password:="justme"

'do your stuff

ActiveSheet.Protect Password:="justme", DrawingObjects:=True, _
Contents:=True, Scenarios:=True

Gord Dibben Excel MVP

On Mon, 29 Nov 2004 17:47:05 -0800, LennyG
wrote:

I wrote a macro to select certain options when reports on my worksheets are
being
printed. The sheets are then protected and when the macro is run, a message
appears stating that the commands could be accessed if the password is
entered (to remove the protection). How could I get the protection to
remain and get the macro to work.
Thanks
Lennox





All times are GMT +1. The time now is 04:19 PM.

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