How to Remove Excel Password Using VBA

Password protection is a common security measure used to safeguard sensitive data in Excel spreadsheets. However, it’s not uncommon for users to forget the passwords they set, leading to restricted access and potential data loss. When faced with such a situation, one might wonder if there is a way to regain access without losing the valuable data within the file. This is where VBA (Visual Basic for Applications) comes to the rescue.  By utilizing VBA macros, you can efficiently remove password protection from Excel files and regain access to your data.

What’s VBA?

VBA stands for Visual Basic for Applications. It is a programming language developed by Microsoft and is integrated into Microsoft Office applications, including Excel, Word, PowerPoint, and Access. VBA allows users to automate tasks, customize functionalities, and create interactive applications within these Microsoft Office programs.

With VBA, users can write small programs called macros that interact with the application’s objects and perform various tasks. Macros are essentially a series of instructions written in VBA code that can be executed to automate repetitive actions, perform calculations, manipulate data, create custom functions, and much more.

How to Remove Excel Password Using VBA

Step 1: Enable Developer Tab: Before you begin, ensure the Developer tab is visible on your Excel ribbon. To enable it, go to "File" > "Options" > "Customize Ribbon." In the right panel, check the "Developer" option, then click "OK."

Step 2: Access Visual Basic for Applications (VBA) Editor: Press "Alt + F11" on your keyboard to open the VBA Editor. This is where you will write and run the VBA macro to remove the Excel password.

Step 3: Insert a New Module: In the VBA Editor, click "Insert" on the menu and choose "Module." This will create a new module where you’ll write the VBA code.

Step 4: Write the VBA Macro: In the newly created module, paste the following VBA code:


Sub RemovePassword()
Dim MySheet As Worksheet
Dim ws As Worksheets
Dim Password As String

On Error Resume Next
Password = InputBox("Enter the password to unlock the sheet:")
On Error GoTo 0

If Password <> "" Then
For Each ws In Worksheets
ws.Unprotect Password
Next ws
MsgBox "Password removed successfully!"
MsgBox "No password provided. The operation has been canceled."
End If
End Sub

Step 5: Run the VBA Macro: Close the VBA Editor and return to your Excel worksheet. Press "Alt + F8" to open the "Macro" dialog box. Select the "RemovePassword" macro and click "Run." If the sheet was protected with the correct password, the protection will be removed, and a confirmation message will be displayed.

Step 6: Save the Unprotected Workbook: After running the VBA macro and removing the password, remember to save the file to retain the changes. You can now access the Excel workbook without the password restrictions.

Important Note:

While VBA offers an effective solution for removing Excel passwords, it’s essential to exercise caution and use this method responsibly. Ensure you have the right to access and modify the protected Excel files, as unauthorized usage may breach data security and privacy policies. Additionally, always keep a backup of your original password-protected file to prevent data loss in case of any unexpected issues during the password removal process.

Alternative: Remove Excel Password using Dr.Excel

iSeePassword Dr.Excel is a third-party software designed specifically for removing Excel passwords. It is a popular password recovery tool known for its effectiveness in unlocking password-protected Excel files.


Using iSeePassword Dr.Excel typically involves the following steps:

  1. Visit the official website of iSeePassword and download the Dr.Excel software. Install it on your computer following the provided instructions. Open the Dr.Excel software on your computer.install_excel_password_recovery_1
  2. Import the Password-Protected Excel File: Click on the "Add" or "Import" button within the Dr.Excel interface to select the password-protected Excel file that you want to unlock.install_excel_password_recovery_2
  3. Choose the Attack Type: iSeePassword Dr.Excel offers different attack types to unlock Excel files, such as Brute Force Attack, Dictionary Attack, and Mask Attack. Select the appropriate attack type based on your specific situation and knowledge of the password.mask_settings_Img
  4. Configure Attack Settings (if applicable): Depending on the attack type chosen, you may need to configure specific settings, such as password length, character sets, or known password elements.
  5. Start the Password Recovery Process: Once you have set up the attack type and settings, click on the "Start" or "Recover" button to initiate the password recovery process.find_excel_password_1
  6. Wait for the Process to Complete: The recovery process may take some time, depending on the complexity of the password. Be patient and wait for the software to complete the password removal process.


Can I Restore the Original Excel File After Using VBA to Remove Excel Password?

Yes, you can restore the original Excel file after using VBA to remove Excel password, provided that you have kept a backup copy of the original file. When using VBA to remove Excel passwords, it’s crucial to take precautionary measures to ensure you have a copy of the password-protected file in case anything goes wrong during the process.

Here’s what you can do to restore the original Excel file:

  • Create a Backup Copy: Before running the VBA macro to remove the password, create a backup copy of the original password-protected Excel file. This backup ensures that you have a safe copy of the file with the password intact.
  • Run the VBA Macro: After creating the backup, run the VBA macro to remove the password from the Excel file. If everything goes smoothly, the password protection will be removed, and you will have an unprotected version of the Excel file.
  • Save the Unprotected Workbook: If the VBA macro successfully removes the password, save the changes to the unprotected Excel file. It is essential to save the file with a new name or in a different location to avoid overwriting the backup copy.
  • Restore from Backup: If any issues occur during the password removal process or if you encounter unexpected data loss, you can easily restore the original Excel file by using the backup copy. Simply open the backup file and access the Excel workbook with the password protection still intact.

Are There Any Risks Associated with Using VBA to Remove Excel Passwords?

Yes, there are some risks associated with using VBA to remove Excel passwords, and it’s essential to be aware of them before attempting the password removal process. While this method can be effective, it requires modifying the underlying structure of the Excel file, which can lead to potential issues:

  • Data Loss or Corruption: Incorrectly implementing the VBA code or making mistakes in the password removal process can result in data loss or corruption of the Excel file. It’s essential to take a backup of the original password-protected Excel file before running the VBA macro to avoid irretrievable damage.
  • Unsupported Excel Versions: VBA may not be compatible with all versions of Excel. While it generally works well with Excel 2003 and later versions, certain older or extremely new versions may have limitations or differences in their VBA capabilities. It’s important to test the VBA code on a copy of the Excel file and ensure it functions as expected.
  • Complex Passwords and Encryption: VBA can effectively remove simple password protection from Excel files, but it may struggle with complex passwords or files that use advanced encryption. Strong passwords or encrypted files may require more sophisticated methods or tools, and attempting to remove such protections with VBA might be unsuccessful.
  • Security Risks: Running VBA macros from unknown or untrusted sources can pose security risks. Malicious VBA code can potentially harm your computer, compromise sensitive data, or spread malware. Always use VBA code from trusted and reputable sources, and ensure that the macro code is transparent and does not contain harmful commands.

To minimize risks, it’s crucial to follow the password removal steps carefully, work with a backup copy of the original file, and ensure that you have the necessary authorization to access and modify the Excel files.


1. Can I use VBA to remove passwords from any version of Excel?

VBA can be used to remove passwords from most versions of Excel, but there may be compatibility issues with very old or extremely new versions. Generally, VBA works well with Excel 2003 and later versions. However, it’s always recommended to test the VBA code on a copy of the Excel file before applying it to the original file, especially when dealing with older versions of Excel.

3. Can VBA remove passwords from encrypted Excel files?

VBA is not designed to remove passwords from encrypted Excel files. Encrypted files use advanced security measures to protect data, and breaking encryption requires a much more complex and often unauthorized approach. VBA is generally effective for removing simple password protections applied directly to Excel workbooks or worksheets, but it cannot bypass encryption.

4. Is removing Excel passwords using VBA legal and ethical?

The legality and ethics of using VBA to remove Excel passwords depend on the context and your rights to access the file. If you are the owner or have proper authorization to access and modify the Excel file, then using VBA to remove the password is generally considered legal and ethical. However, attempting to remove passwords from files you don’t have permission to access or modifying files without proper authorization may be illegal and unethical. Always ensure you have the necessary rights and permissions before using VBA to remove Excel passwords.


Unlocking password-protected Excel files using VBA macros can be a lifesaver when you find yourself locked out of your own data. By following the step-by-step guide above, you can swiftly remove password protection from Excel workbooks and regain access to your valuable information. However, remember to use this method responsibly and ethically, ensuring you have the necessary permissions to access and modify the files. With VBA, you can effortlessly unlock the full potential of your Excel files and enjoy seamless productivity without the hassle of password restrictions.