
There’s one thing that you need to take care of that if you are trying to unprotect a workbook that is w Unprotect a Workbook without a PasswordĪnd if a workbook is protected without a password you can use the same method without specifying the password argument. In the same way, you can use the unprotect method to unprotect the workbook and the code for this would be like something below. If you are trying to protect a workbook without a password that is already protected with a password Excel will show a dialogue box to enter that password.

Workbooks("Book1").Protect "test123"Īnd when I run this code, it locks the “Book1” workbook.Īnd if you want to protect a workbook without a password you need to skip the “Password” argument, just like the following code. In this code, you have the workbook name first and the protection method with the password. Helpful Links: Run a Macro – Macro Recorder – Visual Basic Editor – Personal Macro Workbook Protect a Workbook with Passwordīelow is the code that you need to use to protect a workbook with a password. In this tutorial, we will learn this method in different ways and we will also learn to unprotect a workbook.

By using this method, you can use a password, or even you can activate workbook protection without a password. To protect a workbook, you need to use VBA’s PROTECT method.
