Where Password is an Optional parameter. It specifies a case sensitive password to unprotect the Worksheet. If worksheet is not protected with password then you can ignore this parameter.
In the above syntax we are using ‘Unprotect’ method of Worksheet object to unprotect the Worksheet.
VBA Protect Worksheet Method – Without Password: Example1
Please find the below example, It will show you how to unprotect the Worksheet without password.
Explanation: In the above example we are unprotecting the Worksheet without password by using ‘Unprotect’ method of Worksheet object in the worksheet named ‘Sheet1’. When we are unprotecting the same worksheet it won’t ask any password to unprotect the worksheet.
VBA Protect Worksheet Method – With Password: Example2
Here is the example to Unprotect the Worksheet with password.
Explanation: In the above example we are unprotecting the Worksheet with password by using ‘Unprotect’ method of Worksheet object in the worksheet named ‘Sheet1’. When working with macro or code has password protected, if you want to do any changes in the code first you have to unprotect the password at the beginning of the procedure and at the end of the procedure you have to protect it again. While unprotecting same worksheet it will ask for the password to unprotect the worksheet.
VBA Unprotect Worksheet Method- Instructions
Please follow the below step by step instructions to execute the above mentioned VBA macros or codes:
- Open an Excel Worksheet
- Press Alt+F11 :This will Open the VBA Editor. Otherwise, you can open it from the Developer Tab
- Insert a Module from Insert Menu
- Copy the above code for activating worksheet and Paste in the code window(VBA Editor)
- Save the file as macro enabled Worksheet
- Press ‘F5’ to run it or Keep Pressing ‘F8’ to debug the code line by line and check how the Worksheet has Unprotected.