The fastest way to lock an Excel file

To password protect an Excel file, open the file in Excel, go to File > Info > Protect Workbook, then choose Encrypt with Password. Type your password twice and save the file. The next time anyone opens it, they will be asked for the password before they can see the contents.

This method works the same way on Windows and Mac. The password you create is the only way to open the file — if you forget it, Microsoft cannot recover it for you, so write it down somewhere safe before you close the file for the first time.

Key Takeaways

  • Password protection in Excel prevents anyone without the password from opening the file at all.
  • The process takes under one minute and requires you to type your password twice to confirm it.
  • If you forget the password, there is no recovery option — Microsoft cannot unlock the file for you.
  • You can also restrict editing without requiring a password, which allows people to view the file but not change it.
  • The password feature works identically on Excel for Windows, Excel for Mac, and Excel online.

Step-by-step: Password protecting your file

Open the Excel file you want to protect. Click the File tab in the top left corner of the screen. From the menu that appears on the left, click Info. You will see a section labeled Protect Workbook on the right side of the screen.

Click the Protect Workbook button and select Encrypt with Password from the dropdown menu. A dialog box will appear asking you to enter a password. Type your password in the field — it can be any combination of letters, numbers, and symbols. Click OK.

Excel will ask you to enter the password a second time to confirm you typed it correctly. Type the same password again and click OK. You will return to the Info screen. Now click Save or press Ctrl+S (Windows) or Command+S (Mac) to save the file with the password protection active.

The next time you or anyone else opens this file, a password prompt will appear before the spreadsheet loads. Without the correct password, the file cannot be opened.

What happens when someone tries to open a password-protected file

When a password-protected Excel file is opened, a dialog box appears when ready asking for the password. The person opening the file must type the correct password to proceed. If they type an incorrect password and click OK, Excel will show an error message and return to the password prompt — they can try again as many times as they want.

There is no limit to how many times someone can attempt to enter the password, so a weak password (like "123" or "password") can be guessed. Use a password that combines uppercase letters, lowercase letters, numbers, and symbols to make it harder to guess. A password like "BlueSky#2024!" is much stronger than "excel123".

The difference between password protection and edit restriction

Excel offers two different protection features, and they work in opposite ways. Password protection (Encrypt with Password) prevents anyone from opening the file without the password. Edit restriction (Protect Current Sheet or Protect Workbook Structure) allows people to open and view the file, but prevents them from making changes to it.

Edit restriction is useful when you want to share a spreadsheet with others but do not want them to accidentally delete formulas or change data. Password protection is useful when the file contains sensitive information that should not be seen at all. You can use both at the same time — password protect the file to control who opens it, and also restrict editing to control what they can change once inside.

Removing or changing a password

To remove a password from an Excel file, open the file (you will be prompted for the password). Go to File > Info > Protect Workbook > Encrypt with Password. The password field will be empty. Leave it blank and click OK, then click OK again when prompted to confirm. Save the file. The password protection is now removed.

To change the password, follow the same steps but type your new password instead of leaving the field blank. You must know the current password to change it — if you have forgotten the password, you cannot change it without first removing the protection, which requires knowing the current password.

Why your password might not work after saving

If you set a password but the file does not ask for it the next time you open it, the most common reason is that you did not save the file after setting the password. The password protection only takes effect once you save. Go back to File > Info > Protect Workbook > Encrypt with Password, enter your password again, and then save the file.

Another possibility is that you are opening a copy of the file rather than the original. Check the file name in the title bar at the top of the screen — if it says "Copy of" or has a different name than you expected, you may have opened the wrong file. Make sure you are saving and opening the correct file path.

Password protection on Excel Online and shared files

If you use Excel Online (the browser version), password protection works the same way: File > Info > Protect Workbook > Encrypt with Password. However, if you share the file through OneDrive or SharePoint, the password protection applies to the file itself, not to the sharing link. Anyone with the sharing link will still be prompted for the password when they try to open the file.

If you want to share a file with specific people without password protecting it, use the sharing settings in OneDrive or SharePoint instead. If you want to password protect it and share it, send the file directly to people you trust, along with the password through a separate message (never in the same email as the file).

Frequently Asked Questions

What if I forget the password to my Excel file?

Microsoft cannot recover a forgotten password for an encrypted Excel file. The file cannot be opened without the correct password. To prevent this, store your password in a find location like a password manager or a locked drawer. If you have forgotten the password and have no backup, the file is not recoverable.

Can I password protect just one sheet instead of the whole file?

Yes. Go to File > Info > Protect Workbook and choose Protect Current Sheet instead of Encrypt with Password. This prevents changes to that sheet but does not prevent opening the file. To prevent opening the file entirely, use Encrypt with Password.

Does password protection work if I save the file as a PDF or CSV?

No. Password protection is a feature of Excel files only. If you save an Excel file as a PDF or CSV, the password protection is removed and the file will open without a password. To keep the file protected, save it as an Excel file (.xlsx or .xls).

Can someone break the password if they have the file?

A weak password can be guessed or cracked with software tools. Use a password with at least 12 characters that includes uppercase letters, lowercase letters, numbers, and symbols. Avoid dictionary words, birthdays, or names. A strong password makes breaking in much harder.

Will the password protect the file if I email it to someone?

Yes. The password protection stays with the file no matter how it is sent. When the recipient opens the file, they will be asked for the password. Send the password separately from the file — never in the same email or message.