ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   no password carryover with "protect sheet" in macro (https://www.excelbanter.com/excel-programming/291225-re-no-password-carryover-protect-sheet-macro.html)

Trevor Shuttleworth

no password carryover with "protect sheet" in macro
 
Jeremy

you haven't actually provided a password:

From the Help:

Syntax 1

expression.Protect(Password, DrawingObjects, Contents, Scenarios,
UserInterfaceOnly)

Syntax 2

expression.Protect(Password, Structure, Windows)



So, you need to add something like:

ActiveSheet.Protect Password := "drowssap"Regards

Trevor


"Jeremy" wrote in message
...
I'm hoping to run a macro on a sheet of data and then have the newly

generated sheet be password protected against any alterations. While
recording a new macro, i go to "Sheet Protection..." and protect the sheet
using the optional password feature. This macro, when used later on, creates
a new sheet of data and the sheet is initially protected when trying to
alter a cell (gives the notificiation of "read-only" but also says the sheet
can be unprotected but a password may be required), but if i simply go to
"Unprotect Sheet..." it allows me to do so without entering a password.

The VBA language,

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

doesn't carryover the password for some reason.

any ideas?

Jeremy





All times are GMT +1. The time now is 03:49 AM.

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