Need Macro to unprotect worksheet, sort, then protect worksheet


Posted by Carol on October 09, 2001 10:00 AM

Help please! I have a worksheet that needs to stay protected, but the user will still need sort capabilities. I tried to create a macro that would unprotect the sheet, sort, and reprotect. When I tried to run it, it still asked me for the password. Is there a way to create a macro that will store the password so the user doesn't need it? It seems that giving the user the password defeats the purpose. Any help you can give me would be greatly appreciated. Thank you in advance.

Posted by Anon on October 09, 2001 11:14 AM


ActiveSheet.Unprotect password:="whatever"
ActiveSheet.Protect password:="whatever"

It would also be advisable to protect your code module.




Posted by faster on October 09, 2001 11:17 AM

'just include the password in your code

Sub MySub()
ActiveSheet.Unprotect Password:="mypassword"

'sort code here

ActiveSheet.Protect Password:="mypassword"
End Sub