Family Encyclopedia >> Work

How to Remove VBA Password Protection in Excel: Step-by-Step Guide for XLS and XLSM Files

Locked out of your own Excel VBA project due to a forgotten password? As an experienced Excel developer, I've used this reliable hex-editing technique countless times to recover access without data loss. Note: This method bypasses VBA project locks, highlighting Excel's limitations in code protection—use stronger security for sensitive macros.

We'll first demonstrate setting a password (to create a reference file), then remove it from a protected file. Always back up your workbook first.

How to Set a VBA Password

To understand the process, create a test file with a password-protected macro.

Enable the Developer tab: Go to File > Options > Customize Ribbon, and check Developer in the right pane.

How to Remove VBA Password Protection in Excel: Step-by-Step Guide for XLS and XLSM Files

In the Developer tab, click Macros, name your macro (e.g., "TestMacro"), and click Create.

How to Remove VBA Password Protection in Excel: Step-by-Step Guide for XLS and XLSM Files

How to Remove VBA Password Protection in Excel: Step-by-Step Guide for XLS and XLSM Files

In the Visual Basic Editor, replace the code with:

Range("A1").Value = "Password Protected"

How to Remove VBA Password Protection in Excel: Step-by-Step Guide for XLS and XLSM Files

Go to Tools > VBAProject Properties.

How to Remove VBA Password Protection in Excel: Step-by-Step Guide for XLS and XLSM Files

On the Protection tab, check Lock project for viewing and set a password (e.g., "test123").

How to Remove VBA Password Protection in Excel: Step-by-Step Guide for XLS and XLSM Files

Save as .XLSM, close, and reopen. Accessing Visual Basic prompts for the password.

How to Remove VBA Password Protection in Excel: Step-by-Step Guide for XLS and XLSM Files

How to Remove a VBA Password

Download a free hex editor like HxD. The process varies slightly for .XLS vs. .XLSM.

Prepare XLSM Files

For .XLSM: Rename to .zip, open with an archiver (e.g., 7-Zip). Navigate to the xl folder (or equivalent like SG in some views), extract vbaProject.bin.

How to Remove VBA Password Protection in Excel: Step-by-Step Guide for XLS and XLSM Files

How to Remove VBA Password Protection in Excel: Step-by-Step Guide for XLS and XLSM Files

Disable the Password

Open both your test file's vbaProject.bin (with known password) and the target file's in the hex editor.

In the test file, press Ctrl + F and search for CMG =. Copy the block starting with:

CMG =
DPB =
GC =

How to Remove VBA Password Protection in Excel: Step-by-Step Guide for XLS and XLSM Files

Paste this exact block into the target file at the matching position (after its CMG =), overwriting without deleting surrounding data. Save.

Replace the original vbaProject.bin in the .zip with this edited version, rename back to .XLSM.

Open in Excel, go to Developer > Visual Basic, and enter your test password (e.g., "test123"). Access restored!

How to Remove VBA Password Protection in Excel: Step-by-Step Guide for XLS and XLSM Files

Security Notes

This workaround exposes VBA protection's weakness—it's easily bypassed with basic tools. For real security, compile code into add-ins, use VSTO, or encrypt the entire file. Ideal for recovering your own forgotten passwords, but reconsider relying on VBA locks for sensitive data.

Questions on VBA recovery or tips for better Excel security? Share in the comments below!