Unprotect a Worksheet on Workbook Open

Sometimes you need to unprotect the worksheets in a workbook before continuing your work. If you find that you’re constantly unprotecting worksheets, this macro maybe help you.

Macro Code

Private Sub Workbook_Open()
'Step 1: unprotect the sheet with a password
     Sheets("Sheet1").Unprotect Password:="ExcelHowTo"
End Sub

How This Macro Works

This code is triggered by the workbook’s Open event. When you open a workbook, this event triggers, running the code within. This macro automatically unprotects the specified sheet with the given password when the workbook is opened.

The macro explicitly names the sheet we want to unprotect — Sheet1, in this case. Then it passes the password required to unprotect the sheet. Be aware that Excel passwords are case-sensitive, so pay attention to the exact password and capitalization that you are using.

How to Use This Macro

To implement this macro, you need to copy and paste it into the Workbook Open event code window. Placing the macro here allows it to run each time the workbook opens.

  1. Activate the Visual Basic Editor by pressing ALT+F11.
  2. In the Project window, find your project/workbook name and click the plus sign next to it in order to see all the sheets.
  3. Click ThisWorkbook.
  4. Select the Open event in the Event drop-down list.Workbook Open Event
  5. Type or paste the code in the newly created module, modifying the sheet name (if necessary) and the password. Note that you can unprotect additional sheets by adding additional statements.

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>