Unprotect Method of Worksheet Object VBA

Unprotect Worksheet method in VBA is used to remove protection from the worksheet. If you forgot the password, you cannot unprotect the worksheet. Always better to note down in safe place. We need to Unprotect Worksheet at the beginning of the procedure to do any changes to the Worksheet.

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


When we use Unprotect Worksheet Method in VBA?

Unprotect method of Worksheet object has no effect if the Worksheet is not protected. It removes protection from the Worksheet. We have to use unprotect method of worksheet object to remove password protection from the worksheet. If you forgot the password, you cannot unprotect the Worksheet.

VBA Unprotect Worksheet Method – Syntax

Here is the syntax to Unprotect Worksheet using VBA.

Worksheets(“Your Worksheet Name”).Unprotect(

[Password])

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.

Sub Unprotect_WorkSheet_Without_Password()
Sheets("Sheet1").Unprotect
End Sub

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.

Sub Unprotect_WorkSheet_With_Password()
Sheets("Sheet1").Unprotect "YourPassword"
End Sub

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:

  1. Open an Excel Worksheet
  2. Press Alt+F11 :This will Open the VBA Editor. Otherwise, you can open it from the Developer Tab
  3. Insert a Module from Insert Menu
  4. Copy the above code for activating worksheet and Paste in the code window(VBA Editor)
  5. Save the file as macro enabled Worksheet
  6. Press ‘F5’ to run it or Keep Pressing ‘F8’ to debug the code line by line and check how the Worksheet has Unprotected.
LIMITED TIME OFFER

Leave A Comment


Related pages


excel vba write to text filefso vbaexcel vba open file and copy dataexcel based dashboardsexcel vba format cellblank excel worksheethow to extract duplicates in exceldcl in sqlmacro unprotect sheetexcel macro codingms access nested iifvba change caseexcel developer toolbarmake pivot table in exceldatevalue excelexcel macro case statementmeeting minutes template excel formatreplace in formula excelexcel if blank cellexcel vba insert rowsapplication calculation xlcalculationmanual vbaexcel shortcut select rowsql sort commandadding excel columns2014 calendar template excelplot chart in excelexcel developer tutorialexcel macro loopsredim preserve array vbasql basics interview questionsvb exit buttonexcel macro to select a cellremove password protection from excel 2010ddl dmlvalue vbahow do i remove blank rows in excelexcel formulas with examples in excel sheet vlookuphow to develop macros in excelhow to place a tick in excelhow to use the vlookup function in excel 2013free gantt charts in exceluses of macros in excelmonthly gantt chart excel templateexcel vlookup isnaexcel count filled cellsexcel sheet vbaexcel vba 2d arrayworksheet and workbookpassword protected excel sheetdefination of vlookuphow to adjust cell width in excelexcel meeting templateproject proposal template excelcheckbox in excel 2007excel formula duplicateshow to filter out duplicates in excelbuilding a graph in excelhow to create a pie chart in excel 2007form excel vbalook up formula in excelexcel macro break loopexcel vba ribbonexcel 2010 vlookup examplevba cell rowvba cell selectionvba code to read excel fileexcel with vba programminghow to find the duplicate values in excelconstruction budget template excelexcel vba forecolorshow userform vbaif statements excel 2010run vba in excelautofit cells in excelinterior colorindexvba xlrightbar of pie excelhow to check duplicate values in excel