How to Lock an Excel File With a Password to Open It

How-to basics · Updated November 20, 2026

To lock an Excel file so nobody can view it without a password, open it in Excel for Microsoft 365 on Windows and choose File > Info > Protect Workbook > Encrypt with Password. Enter and confirm a strong password, save the workbook, then close and reopen it to check that Excel asks for the password before showing the contents. This encrypts the file; it is different from protecting a worksheet or preventing edits.

What You’ll Need

  • A desktop version of Excel for Microsoft 365 on Windows and permission to edit the workbook. Excel for the web cannot add password-to-open encryption.
  • The workbook saved in a format Excel supports, such as .xlsx or .xlsm.
  • A strong password stored somewhere safe, such as a reputable password manager. Excel cannot recover a forgotten password for an encrypted file.

Step-by-Step

  1. Choose the right file and make a backup. Find the workbook you want to protect and consider saving a separate backup before changing its security settings. Make sure you are working on the intended copy, especially if the file is in a shared folder or synced through OneDrive. A backup is useful if you later need an unencrypted copy or discover that another person or system needs access. Store any backup with appropriate access controls; an unprotected duplicate defeats the purpose if it is easy to find.
  2. Open the workbook in the Excel desktop app. If you opened it in a browser, choose the option to open or edit it in the desktop app, if available. Password encryption for opening is a desktop feature. Excel for the web does not let you set this protection, and password-encrypted files may need to be opened in desktop Excel rather than edited in the browser.
  3. Open the encryption command. In Excel for Microsoft 365 on Windows, select File > Info > Protect Workbook > Encrypt with Password. The Protect Workbook menu includes several protections. Choose Encrypt with Password specifically: protecting the workbook structure or a sheet is not the same as requiring a password before the file opens.
  4. Enter a strong password. Type a password in the dialog, then select OK. Use a long, unique passphrase that is difficult to guess. A mixture of unrelated words or a password-manager-generated password is safer than a name, date, company name, or short phrase someone could infer. Excel passwords are case-sensitive, so uppercase and lowercase letters must be entered exactly as saved.
  5. Confirm the password carefully. Type the same password again when Excel asks you to confirm it, then select OK. If the confirmation does not match, Excel will ask you to try again. Before proceeding, check the spelling, capitalization, and any symbols. If you use a password manager, save the exact password there with a clear label identifying the workbook, rather than relying on memory.
  6. Save the workbook. Select File > Save or press Ctrl+S on Windows. Encryption is applied to the saved file, so do not assume that entering a password alone has completed the change. Wait for saving or syncing to finish if the file is stored online. If Excel displays a compatibility or format warning, read it before choosing an option; changing file formats can affect features such as macros or other workbook content.
  7. Close the file and test the protection. Close the workbook, then open it again from its saved location. Excel should request the password before displaying the workbook. Enter the password and check that the file opens normally. If the prompt does not appear, confirm you opened the protected copy rather than an older duplicate, and repeat the encryption steps on the correct file.
  8. Share access securely. Send the encrypted workbook only to people who should have access. Give the password through a separate, reasonably secure channel instead of putting it in the same email or message as the attachment. For a team file, consider whether each recipient can store and use the password safely. Anyone who knows the password can open the workbook, so encryption does not replace careful decisions about who receives the file.
  9. Change or remove the password only when needed. To change it, open the workbook with its current password and return to File > Info > Protect Workbook > Encrypt with Password. Enter and confirm a replacement, then save and test the file again. To remove the opening password, use the same command, delete the password from the entry box so it is blank, confirm the change, and save. Keep in mind that removing encryption makes the saved workbook accessible without that password.

On a Mac: Excel for Mac has a different interface. In supported desktop versions, open the workbook and choose File > Passwords, then set a password in the field for opening the file and confirm it. Save, close, and reopen the workbook to verify the prompt. Labels and availability can vary by Excel for Mac version. Excel for the web does not provide this setting; use the desktop app.

Common Mistakes

  • Choosing sheet protection instead of file encryption. Review > Protect Sheet limits changes to a worksheet, and workbook-structure protection limits changes such as adding or moving sheets. Neither is a substitute for Encrypt with Password when the goal is to stop someone opening the file. Worksheet protection is useful for controlling edits after opening, not hiding the workbook contents.
  • Forgetting or mistyping the password. A typo during confirmation is usually caught, but a password can still be lost later or saved incorrectly. Passwords are case-sensitive. Record the final password in a secure password manager and, if practical, verify that you can retrieve it before relying on the protected workbook.
  • Sharing the password alongside the file. An attachment and its password in the same email are effectively delivered together. Use a separate channel and avoid posting passwords in shared documents, chat rooms, or file names. If several recipients need access, share it only with the intended people.
  • Leaving another unprotected copy available. A protected workbook does not secure earlier downloads, email attachments, temporary copies, or exports. Check shared folders and the location from which you are distributing the file. Remove copies only if you have authority to do so and have confirmed they are not needed.
  • Confusing encryption with access permissions. Anyone who receives the file and its password can open it, and a password does not control whether someone can forward a copy. For cloud files, also review OneDrive or SharePoint sharing permissions and remove access for people who no longer need it.

Tips

  • Use a unique password for each sensitive workbook. Reusing a password means that exposure of one file could put other files at risk.
  • Keep the password separate from the workbook and make sure an appropriate colleague can retrieve it if the owner is unavailable. Plan this before distributing business-critical files.
  • Test the exact copy you plan to send. A quick close-and-reopen check catches mistakes such as protecting one version while attaching another.
  • For files stored in OneDrive or SharePoint, encryption and sharing permissions serve different purposes. Use the sharing controls to decide who can access the cloud file, and use an opening password when recipients also need to be prompted for a password.
  • If you need to protect only certain cells from accidental edits, sheet protection may be more convenient. If your aim is to keep the contents private before opening, use file encryption. You can combine approaches, but each solves a different problem.

Troubleshooting

Excel does not ask for a password when reopening. Check that you used Encrypt with Password rather than Protect Sheet or Protect Workbook structure. Close the workbook and make sure you reopened the same saved file, not a local download, email attachment, or older copy. If the file is in a synced folder, wait until syncing completes and verify the saved version.

The password is rejected. Check capitalization, keyboard layout, Caps Lock, and any symbols in the password. If you copied it from a password manager, make sure you did not include an extra space at the beginning or end. Try the stored original rather than guessing repeatedly. Excel does not provide a normal recovery option for a forgotten opening password; contact the person who created the file or check your organization’s approved password records. Be cautious of third-party services claiming they can recover it, especially for confidential workbooks.

The encryption option is missing or unavailable. Confirm that you are using the desktop Excel app and have opened the workbook for editing, not viewing it in a browser or in a read-only state. Some organizational policies, file formats, or compatibility situations can limit available commands. Save a separate copy in a supported Excel format if appropriate, then check the command again. Do not convert a macro-enabled .xlsm workbook to .xlsx unless you are prepared to lose its macros.

The file opens on one device but not another. Confirm that the other device is using a compatible desktop version of Excel and that the password is being entered exactly. Excel for the web may not support opening or editing an encrypted workbook, so download or open it in desktop Excel. If the file was renamed or copied, verify that you are testing the encrypted version rather than an unprotected duplicate.

A recipient says the workbook is damaged or will not open. Ask them to open it in a current desktop version of Excel, enter the password in the prompt, and avoid renaming or converting the file before testing. You can test the same shared copy yourself. If it still fails, compare it with your backup and resend the correctly saved file through an approved channel. Do not send an unencrypted version unless its contents can safely be exposed.

Frequently Asked Questions

Does a password to open stop people from viewing the workbook?
It encrypts the workbook so Excel requests a password before opening its contents. It does not prevent someone who has the password from viewing, copying, or sharing the file. Use file-sharing permissions as an additional control when appropriate.

Is protecting a sheet the same as locking an Excel file?
No. Sheet protection restricts certain edits after the workbook is open. An opening password is applied through Encrypt with Password and is intended to prevent opening the workbook without the password.

Can I open a password-protected workbook in Excel for the web?
Excel for the web does not set opening-password encryption and may not support opening or editing an encrypted workbook. Use the desktop Excel app on Windows or Mac for the password-protected file.

What happens if I forget the opening password?
Excel has no standard password-reset or recovery feature for an encrypted workbook. Check your password manager or ask the file owner or your organization’s administrator whether an authorized copy or record exists. Keep a secure record before you need it.

Can I remove or change the password later?
Yes, if you can open the workbook with its current password. In Windows Excel, use File > Info > Protect Workbook > Encrypt with Password, enter a replacement or clear the password field, and save. Reopen the file afterward to check the result.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.