I need to add code to an existing macro that will first unlock the current sheet that is protected with a password of "password" and then re-lock it at the end using the same password. Thanks.
I need to add code to an existing macro that will first unlock the current sheet that is protected with a password of "password" and then re-lock it at the end using the same password. Thanks.
Could use a function. Then you can check whether the unlock was successful
Example UsagePlease Login or Register to view this content.
Please Login or Register to view this content.
Thanks but I would rather keep it in the macro. Is that possible?
Sure
Please Login or Register to view this content.
I couldn't get that to work. Here is my current code that needs to be the "else"
Please Login or Register to view this content.
Thank you for this and it worked. But I need to add something. When the sheet is protected using this code, it only allows locked and unlocked cells to be selected. I need it to allow a few other things when locked.
1) Delete Rows
2) Sort
3) Use Autofilter
Can you please help with this? Thanks.
That's not obvious from your code. Just record a macro while you protect the sheet with the criteria you require. Then copy and paste that into your code (together with the password line).
Trevor Shuttleworth - Retired Excel/VBA Consultant
I dream of a better world where chickens can cross the road without having their motives questioned
'Being unapologetic means never having to say you're sorry' John Cooper Clarke
I will try that but here is the protect code.
Please Login or Register to view this content.
Have you recorded the criteria?
Something like this:
Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks