Unprotect Method of Workbook Object VBA

We need to unprotect workbook at the beginning of the procedure to do any changes to the workbook. If you forgot the password, you cannot unprotect the workbook.



50+ Project Management Templates Pack
Excel PowerPoint Word

Advanced Project Plan & Portfolio Template
Excel Template

Business Presentations Templates Pack
PowerPoint Slides

20+ Excel Project Management Pack
Excel Templates

20+ PowerPoint Project Management Pack
PowerPoint Templates

10+ MS Word Project Management Pack
Word Templates

Why we need to Unprotect a Workbook using VBA?

Unprotect method of workbook object has no effect if the workbook is not protected. It removes protection from a workbook.

VBA Unprotect Workbook – Syntax

Here is the syntax to Unprotect workbook using VBA.

Workbooks(“Your Workbook Name”).Unprotect(

[Password], [Structure], [Windows])

Password: Its Optional argument. It specifies a case sensitive password for the workbook. When you want to unprotect your protected workbook you must specify your password.
Structure: Its Optional parameter. The default value is False. If we mention it as True that means protect the workbook structure.
Windows: Its Optional parameter. The default value is False. If we mention it as True that means protect the workbook windows.
In the above syntax we are using ‘Unprotect’ method of workbook object to unprotect the workbook.

VBA Unprotect Workbook: Example 1

Please find the below example, It will show you how to Unprotect the workbook.

Sub Unprotect_Sheet()
ActiveWorkbook.Unprotect “YourPassword”, True, True
End Sub

In the above example we are unprotecting the workbook by using ‘Unprotect’ method of Workbook object in the active workbook. When working with workbook code has password Unprotected, if you want to do any changes in the code first you have to Unprotect the password at the beginning of the procedure and

VBA Unprotect Workbook – Instructions

Please follow the below step by step instructions to execute the above mentioned VBA macros or codes:

  1. Open an Excel Workbook
  2. Press Alt+F11 to Open VBA Editor
  3. Insert a Module from Insert Menu
  4. Copy the above code for activating a range and Paste in the code window(VBA Editor)
  5. Save the file as macro enabled workbook
  6. Press ‘F5’ to run it or Keep Pressing ‘F8’ to debug the code line by line.

Leave A Comment

Related pages

excel reporting templates dashboardexcel merge sheets into onerowsource vbahow to unlock a excel file protected by passwordexcel linked cellsmerge multiple excel sheets into onehow to collapse rows in excelhow to create defined names in excelvlookup excel formulas with examplesaccess 2013 activex controlsdeveloper ribbon excel 2007excel macro formulassumifs function in excel 2010building a graph in excelvba eventsexcel 2010 multiple if statementsvba connect to sql servervb6 sql server connection stringvba stringmatch function in excel 2013lookup formula in excelexcel add developer tabvba current celldeclaring public variables in vbavb source code examplesvba application calculationexample of dmlunhiding column avba code open filehow to enter a macro in excelcreate folder vbainstr syntaxexcel if clausedelete vbamicrosoft dashboard templatessimple vba codeexcel chart formattingexcel bar of piechart title excel 2007how to lock worksheet in excel 2007how do you merge cells in excel 2013excel duplicate removerexcel vba delete sheetmicrosoft word macro examplesvba excel hide columnvba and macrosexcel vlookup rangehow to do descending order in excelvba as doubleexcel countifs functioncreate dashboards in excelexcel vba for stepvba columnwidthit interview questions and answers for freshers pdfprotect cells excel 2007excel vb macroexcel remove checkboxexcel deleting blank rowsdescending order in excelcell shading in excelvba excel colorindexexcel protected worksheet forgot passwordinterior.colorindextick on excelcalculate vba excelexcel hlookuphow to create a countif formula in excelexcel 2010 macro securityexcel if cell equals thendelete sheet in exceliserror vbaconstruction project template excelaccess 2007 msgboxfresher interview questions and answersisempty vba excel