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.

PREMIUM TEMPLATES LIMITED TIME OFFER

ON SALE80% OFF

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])

Where
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.
LIMITED TIME OFFER

Leave A Comment


Related pages


deleting duplicates excelprotecting excel sheetcountif formula excel 2007vba for loop stepexcel vba delete columnsvba transposelen excel functionsql pivot explainedsql questions and answers for written testmacros in excel tutorial for beginners pdfif clause excelcreating a pie chart in excel 2010vlookup formula in exceladvanced excel test questions and answersvba saveas methodhow to remove duplicates from two columns in excelexcel 2010 bubble chartsql important interview questionsexcel vba saveasexcel sharing workbookautosave in excel 2007vba timevaluevba array lengthexcel functions and formulas with examplespowerpoint dashboard templatesvba update recordsetexcel 2010 nested ifexcel macro column widthconverter excel to csvexcel consolidate multiple workbookswhy we use hlookup in excelname manager excel 2007vba workbooks.openadd chart title excelremove duplicates from column in excelcheckbox syntaxexcel remove duplicates from multiple columnslookup function excel 2007hide macros in excelvba close formexcel macro columnbest excel vba bookvba countahide macros in excelvba change cell colorexcel logical and operatorhow to apply filters in excelhow to access vba in excel 2007excel formulas 2007 with examples in excelpassword log template excelvba range copyhow do you do a tick in excelfinding duplicate cells in excelexample vba codeexcel 2007 advanced tutorialexcel vba switchmsgbox iconmsgbox yes no cancelhow to make if statements in excelvba listbox columnsduplicate values excelvba print pdfexcel vba code if then statementexcel vba variantms excel formulas list with examplesexcel vba booleanexcel unprotect sheet vbarecording macros in excelexcel advanced shortcutsnested vlookupshow to hide formula in excel without protecting sheethow do i delete empty rows in excel