[Excel] allow macro in protected sheet

herve3168 Posted messages 2 Registration date   Status Membre -  
 LN -
Hello,
Desperate

How can I enable the use of macros in a protected sheet in EXCEL????

Thank you in advance.

1 réponse

yverchu Posted messages 1 Status Membre 50
 
Execute a macro on a protected sheet

You have just protected a sheet in your workbook with a password, but you would like to run a macro on this sheet. Unfortunately, the macro refuses to work and returns an error message.

To be able to run a macro on a protected sheet, you need to add an instruction that removes the protection before acting on the sheet and another that restores the protection at the end of the procedure.

Sub MacrowithProtectedSheet()

ActiveSheet.Unprotect "thepassword"

'Place your instructions here

ActiveSheet.Protect "thepassword", True, True, True

End Sub

Replace "thepassword" with your password that protects the sheet.
57
Gael
 
A thousand thanks for this very useful advice,
Best regards,
Gael
0
Charlotte.L-SBP
 
Indeed, great formula!! But once my formula is applied, the filters no longer work. Do you have a macro to integrate that could unblock me?
Thank you !!
1