ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Protecting sheet in a macro doesn't work (https://www.excelbanter.com/excel-programming/403453-protecting-sheet-macro-doesnt-work.html)

Andyjim

Protecting sheet in a macro doesn't work
 
I have a macro that moves data from one sheet to another. It is necessary to
unprotect sheets during the data move, then re-protect them after. I protect
the sheets manually before running the macro, using the same password the
macro uses. But after the macro has run, I find I can unprotect the sheet by
hitting ToolsProtectionUnprotect sheet, and it does not ask for a password;
it goes ahead and unprotects the sheet. Prior to running the macro, it does
ask for the password before unprotecting the sheet. The macro definitely is
reprotecting with the same password. Need to solve this to protect formula
cells in one sheet, and data in the other. I've also tried not protecting
them manually at all, just letting the macro do it. Same result.

This is what I'm using in the macro:
ActiveSheet.Protect Password:="XXXXX"
ActiveSheet.Unprotect Password:="XXXXX"



Andyjim

Protecting sheet in a macro doesn't work
 

Hey, I fixed it. Bad syntax. No more problem. Thanks anyway & Happy New Year.


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

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