Question : Run macro on protected sheet without asking for password

Hi experts!

I have a worksheet with protected cells that is protected from user intervention. I have a macro that is supposed to run on these cells (by filling in with color depending on value), but the macro stops when the sheet is protected. I tried to insert a piece of code like : With Sheets(ActiveSheet.Name)
        .Unprotect

but now the code asks the user for a password. If I enter the password, the code continues to run, but that's not exactly what I want to do.

I want to unprotect the sheet, run the code, reprotect the sheet, without user intervention and without the user having to know the password.

Thanks for your help!!
Andreea

Answer : Run macro on protected sheet without asking for password

This should work for you Andreea:
ActiveSheet.Unprotect Password:="XXXX" where XXXX is your password
also
ActiveSheet.Protect Password:="XXXX" to restore protection
Cheers...Terry
Random Solutions  
 
programming4us programming4us