How to Unprotect Excel Sheet Password
In this article
Yes, you can remove a worksheet password, but it requires using the VBA Editor because Microsoft removed the simple interface option in modern versions. This method removes the password protection entirely, allowing you to edit cells, insert rows, or change formatting without entering a code. You will need a copy of the original file saved in a compatible format, as VBA changes cannot be saved natively in older Excel formats like .xls.
What You'll Need
- A computer running Windows or macOS with Microsoft Excel installed.
- The password-protected Excel file on your desktop or in a folder you can access.
- Administrative rights to install or run VBA macros, though no installation is actually required for this method.
- A backup of the original file. This guide modifies the file's structure using VBA, so always keep a safe copy of the source before making changes.
Step-by-Step
- Open the File. Launch Microsoft Excel and open the password-protected workbook. If Excel prompts you for a password when opening the file, enter it and click OK. Once the file is open, do not save any changes yet.
- Enable Editing (if prompted). If the file is protected but not encrypted with a password for opening, you may see a yellow banner at the top saying "Protected View" or "Enable Editing". Click the "Enable Editing" button to proceed.
- Open the VBA Editor. On the keyboard, press the keys Alt + F11 simultaneously. This will open the Visual Basic for Applications (VBA) window. This window is separate from the main Excel spreadsheet and is used to write and run small programs called macros.
- Insert a New Module. In the VBA window, go to the top menu and click Insert > Module. A blank window will appear on the right side of the editor. This window is where you will type the code that removes the protection.
- Enter the Unprotect Code. Click inside the blank module window and type or paste the following line of code exactly as shown. This command tells Excel to look for any protected sheets in the current workbook and remove their password protection.
Dim ws As Worksheet For Each ws In ThisWorkbook.Worksheets ws.Unprotect Next wsMake sure there are no extra spaces at the start or end of the lines, and that the lines are not broken across two lines. The code consists of three lines: a declaration, a loop, and an end loop. - Run the Code. With the code typed in the window, close the VBA window to return to Excel. You can now save the file. The protection is now removed. You can go to the "Review" tab in Excel and click "Unprotect Sheet" to verify that it no longer asks for a password. You can now edit cells, add formulas, and change formatting as needed.
Alternative Method for macOS
If you are using a Mac, the keyboard shortcut Alt + F11 may not work as it does on Windows. Instead, you can use the mouse to access the VBA editor:
- Open the Excel file and ensure it is editable.
- Go to the menu bar and click Tools > Macro > Visual Basic Editor. (Note: In some newer versions of Excel for Mac, the menu path may be Developer > Visual Basic. If you do not see these options, go to Excel > Preferences > Customize Ribbon and add the Developer tab to the toolbar.)
- Follow steps 4 and 5 above to insert the module and paste the code.
- Run the code and save the file.
Common Mistakes
- Typing the Code Manually: The code above is short, but it is easy to miss a word or get a letter wrong. Copying and pasting from this guide is the safest way to ensure the code works correctly. If you type it yourself, double-check every character.
- Forgetting to Save: The VBA code only takes effect when you save the workbook. If you run the code but close the file without saving, the protection will remain in place for the next time you open the file.
- Using the Wrong Format: You cannot save a file that contains VBA macros in the older .xls format. You must save the file as .xlsx or .xlsm (macro-enabled workbook) to retain the change. If you save as .xlsx, Excel will warn you that the VBA code will be removed.
- Using the Wrong Shortcut: On Windows, Alt + F11 is the standard shortcut. On some laptops, you may need to hold the Fn key while pressing Alt + F11 to trigger the VBA editor.
Tips
- Protect the Workbook Structure: After removing the sheet password, it is a good idea to protect the workbook structure to prevent others from deleting important sheets. Go to the Review tab and click Protect Workbook. You can set a password here if you wish, but you can also leave it blank to simply lock the structure.
- Check for Multiple Sheets: The code above loops through every sheet in the workbook. If you have multiple password-protected sheets, this method will unprotect all of them at once. This is usually what you want, but be aware that it will work on all sheets, not just the one you are currently viewing.
- Use a Test File First: Before running this on an important financial or company document, create a small test file with one protected sheet and run the code on it. This will help you get familiar with the process and ensure that the code works on your specific version of Excel.
- Keep the VBA Code Safe: Once you have successfully removed the password, you can delete the code from the module window. This keeps your workbook clean and removes any trace of the password removal process. To delete the code, simply click inside the module window and press Ctrl + A to select all, then press the Delete key.
Troubleshooting
If the code does not work or you receive an error message, follow these steps to diagnose the issue.
- Check for Syntax Errors: If you typed the code yourself, ensure there are no missing colons (:), quotes, or parentheses. The code must be exactly as shown in the guide. A single missing character will cause the code to fail.
- Ensure the File is Saved: The most common reason the code fails is that the file has not been saved since the code was run. Go to File > Save and try running the code again.
- Verify the Format: Ensure the file is saved as an Excel Workbook (.xlsx) or Macro-Enabled Workbook (.xlsm). If you saved it as a PDF or a text file, the VBA code will not work. Open the file in Excel and check the file extension in the file name.
- Check for Read-Only Access: If the file is saved on a network drive or a read-only folder, Excel may not be able to save the changes. Try copying the file to your desktop or a local folder and running the code on the copy.
- Excel Version Compatibility: The method described here uses standard VBA commands that are supported by all modern versions of Excel for Windows and Mac. However, very old versions of Excel (from the early 2000s) may not support the
Unprotectmethod in the same way. If you are using an extremely outdated version of Excel, you may need to upgrade to a newer version to use this method.
Frequently Asked Questions
Is it legal to remove an Excel password?
Removing a password from a document you own or have permission to edit is generally legal. However, removing a password from a document belonging to someone else without their consent may violate copyright laws or terms of service. Always ensure you have the right to access and modify the file before attempting to remove its protection.
Will this method remove the password to open the file?
No, this method only removes the password that protects the individual sheets (formatting, formulas, or cell locking). It does not remove a password required to open the file itself. If you are locked out of the file because you do not know the opening password, this method will not work.
Can I use this method on an Excel for iPad file?
Excel for iPad does not support the VBA Editor or macros in the same way as the desktop version. You cannot use the code-based method described above on an iPad. You must use a Windows or Mac computer to remove the password protection.
What if the code says "Run-time error 1004"?
A runtime error 1004 usually means Excel cannot find a sheet to unprotect or there is a syntax error in the code. Double-check that the file is saved and that you have pasted the code correctly. If the error persists, try saving the file as a different name to rule out file corruption.
Can I use this method on Google Sheets?
No, Google Sheets is a web-based application and does not support VBA. The method described above relies on the VBA Editor, which is a feature of the desktop Excel application. You cannot use this method to unprotect a spreadsheet stored in Google Sheets.
Is it safe to run VBA code on my computer?
The code provided in this guide is safe and does not contain any viruses or harmful scripts. It simply tells Excel to look at the sheets in the current workbook and remove their protection. However, it is always good practice to be cautious when running code from the internet. Only run code that you have copied from a trusted source.