View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Andyjim Andyjim is offline
external usenet poster
 
Posts: 70
Default 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"