How Do I Edit Locked VBA Code in Excel?

Author : Amit Kumar | Published On : 02 Sep 2026

If you open an Excel workbook and find that the VBA code is locked, you may not be able to view or edit the code in the Visual Basic Editor. This can be confusing, especially when you need to fix an error, update a macro, or make a small change to an old Excel file.

VBA code can be locked by the person who created the workbook. In many cases, the VBA project is protected with a password to stop other people from viewing or changing the code.

If you own the workbook or have permission from its owner, there are several things you can check before trying to edit the code.

Why Is VBA Code Locked in Excel?

Excel allows users to protect a VBA project with a password. When this protection is enabled, the code can still run, but you cannot open and edit the VBA modules without unlocking the project.

You may see the "VBAProject is locked" message when you try to view the code.

This can happen with:

  • Old Excel files that contain macros
  • Company workbooks
  • Excel templates
  • Automated reports
  • Custom business tools
  • Files created by another employee
  • Workbooks where the developer has left the company

The important point is that VBA project protection is different from normal worksheet protection. Unlocking a sheet does not automatically unlock the VBA code.

Can I Edit Locked VBA Code Without the Password?

Normally, Excel does not provide a built-in option to edit a password-protected VBA project without the correct password.

If you know the password, the process is simple:

  1. Open the Excel workbook.
  2. Press Alt + F11 to open the Visual Basic Editor.
  3. Select the protected VBA project.
  4. Enter the password when Excel asks for it.
  5. Open the required module.
  6. Make your changes.
  7. Save the workbook.

If you do not know the password, first try to contact the person who created or managed the workbook. This is the safest option because the password may protect important business logic or confidential code.

What If the Original Developer Is Not Available?

Sometimes the person who created the Excel file is no longer available. You may still need access because the workbook is important for your daily work.

Before doing anything else, make a backup copy of the original file. Keep the original unchanged so you have something to return to if a problem occurs.

You can also check:

  • Old project documents
  • Company password records
  • Previous versions of the workbook
  • Shared folders
  • Backup files
  • Internal IT records
  • The original developer's notes

If the VBA project belongs to your company and you have permission to recover access, a VBA password recovery or removal tool may be useful.

For example, Sys Tools vba password remover can be considered when you have a legitimate need to regain access to your own or authorized VBA project.

What Does a VBA Password Remover Do?

A VBA password remover is designed to help users regain access to VBA projects when the original password is no longer available.

This can be helpful when you need to:

  • Edit existing VBA code
  • Fix a macro error
  • Update an old automation
  • Recover access to a company workbook
  • Maintain a legacy Excel application
  • Change VBA instructions
  • Review code that your organization owns

The exact process can vary depending on the software and the Excel file. Always work on a copy of the workbook first.

Will Removing VBA Protection Delete My Macros?

A proper recovery process should aim to preserve the VBA project and the workbook data. However, you should always create a backup before making any changes.

This is especially important if the workbook contains:

  • Important formulas
  • Reports
  • User forms
  • Macros
  • Charts
  • External links
  • Business records

Never test a recovery process on the only copy of an important Excel file.

What If the VBA Code Opens but I Still Cannot Edit It?

There are several different types of Excel protection, so it is important to identify what is actually locked.

For example, you may be dealing with:

Worksheet protection:
Stops users from changing protected cells or certain sheet settings.

Workbook protection:
Can restrict changes to the workbook structure.

VBA project protection:
Stops users from viewing or editing the VBA source code.

These protections are separate. Removing worksheet protection will not necessarily give you access to a locked VBA project.

What Excel Files Can Contain VBA Code?

VBA is commonly found in macro-enabled Excel files such as:

  • .xlsm
  • .xls
  • .xltm
  • .xlam

A normal .xlsx file does not store VBA macros.

If you are working with an older Excel file, check the file extension before trying to recover or edit its VBA project.

How Can I Avoid Losing VBA Code?

The best way to avoid this problem in the future is to keep a safe copy of the VBA source code.

If you manage an Excel-based application, keep:

  1. A working copy of the workbook.
  2. A backup copy.
  3. A record of the VBA project password.
  4. A separate copy of important VBA source code.
  5. Notes explaining what the macros do.

This can save a lot of time when the original developer is unavailable.

More Products from SysTools

 

Final Thoughts

A locked VBA project can make it difficult to fix macros or update an old Excel workbook. If you know the password, you can unlock the project through Excel's Visual Basic Editor. If the password has been lost and you have legitimate ownership or permission to access the code, you can look at recovery options such as a VBA password removal tool.

Most importantly, keep a backup of the original workbook before making any changes. This gives you a safe copy while you work on recovering or editing the VBA code.