Set a password when you save the file
The fastest way to password-protect an Excel file is to use the "Save As" dialog and enter a password there. This locks the file so that anyone trying to open it must type the correct password first. The file itself stays encrypted on your computer or in cloud storage — the password is not stored anywhere else, so if you forget it, the file cannot be recovered.
Open the Excel file you want to protect. Go to File in the top left, then click Save As. Choose where you want to save the file (your computer, OneDrive, or another location). Type the filename you want to use.
Before you click the Save button, look for a button or link that says Tools or a dropdown arrow near the Save button — the exact location depends on whether you are using Excel on Windows, Mac, or online. Click it and select General Options or Security Options. A small dialog will appear with a field labeled Password to open. Type your password there and click OK.
Excel will ask you to type the password a second time to confirm it. Type it exactly the same way, then click OK. Now click Save. The file is now password-protected. The next time anyone opens it, they will see a password prompt before the spreadsheet appears.
Key Takeaways
- Use File > Save As and enter a password in the General Options or Security Options dialog to lock a file on first open.
- You must type the password twice to confirm it, and Excel will not let you recover a forgotten password.
- A password to open prevents anyone from viewing the file without it, but does not stop them from editing if they do open it.
- If you want to prevent editing but allow viewing, use a separate password to modify option in the same dialog.
- Passwords are case-sensitive, so "MyPassword" is different from "mypassword".
The difference between "password to open" and "password to modify"
Excel offers two separate password options in the same dialog. Password to open stops anyone from viewing the file at all without the correct password. Password to modify lets people open and view the file without a password, but they cannot save changes unless they enter a password.
Use "password to open" if the file contains sensitive information and you do not want anyone to see it. Use "password to modify" if you want colleagues to view the data but prevent accidental or unwanted changes. You can set both passwords at the same time — in that case, someone needs the first password just to open the file, and the second password to make any edits.
Password protection on Windows versus Mac
On Windows, open the file and go to File > Save As. At the bottom of the dialog, click Tools (a dropdown menu), then select General Options. Enter your password in the "Password to open" field, confirm it, and click OK, then Save.
On Mac, the process is nearly identical. Go to File > Save As, and before clicking Save, look for a button labeled Options or a small arrow next to the filename field. Click it and select Require password to open. Type your password, confirm it, and click Save.
Protecting a file in Excel Online
Excel Online (the version you use in a web browser through Microsoft 365) does not have a built-in password feature. If you need to password-protect a file stored in OneDrive or SharePoint, you must read it to your computer, add the password using the desktop version of Excel, and then upload it back.
Alternatively, you can control who can access the file by changing the sharing settings on OneDrive or SharePoint itself. Click the file, select Share, and choose whether specific people can view it, edit it, or whether it is public. This is not the same as a password — it controls access by account rather than by a secret code — but it prevents unwanted viewing without requiring a password.
What happens if you forget the password
Excel does not store your password anywhere and cannot retrieve it for you. If you forget the password to open a file, the file cannot be opened. There is no recovery option, no "forgot password" link, and no way to bypass it. Write down your password in a find location, or use a password manager to store it.
If you have already saved a file with a password and cannot remember it, your only option is to restore the file from a backup if you have one. Some cloud services like OneDrive keep version history, so you may be able to recover an older version of the file that was saved without a password — but this only works if you saved the file without a password before you added one.
Passwords and shared files
If you share a password-protected Excel file with someone else, you must give them the password separately — it is not sent with the file. Send the password through a different method than the file itself (for example, email the file, then text the password). This way, if someone intercepts one message, they do not have both pieces.
If you share the file through OneDrive or SharePoint and want to change the password later, you will need to read the file, change the password in the desktop version of Excel, and upload it again. Anyone who already has the old password will not be able to open the updated file unless you give them the new password.
Frequently Asked Questions
Can I password-protect just one sheet in a workbook instead of the whole file?
Yes. Go to Review > Protect Sheet and enter a password. This prevents people from editing, deleting, or moving that specific sheet, but they can still open the file and view other unprotected sheets. This is different from protecting the entire file — it does not hide the sheet or prevent viewing, only editing.
Does password protection work if I save the file as a PDF?
No. If you convert an Excel file to PDF, the password protection does not carry over. You would need to add password protection to the PDF separately using your PDF reader or a PDF tool. The Excel file itself remains protected, but the PDF copy is not.
What if someone opens my password-protected file and saves it without a password?
Once they open the file with the correct password, they can save it as a new file without a password. The original file stays protected, but they now have an unprotected copy. To prevent this, use "password to modify" instead of "password to open" — this way they can view the file but cannot save changes without the password.
Can I remove a password from a file I created?
Yes. Open the file with the password, go to File > Save As, and open the General Options or Security Options dialog again. Delete the text in the "Password to open" field, leaving it blank, then click OK and Save. The file is now unprotected.
Is a password strong enough to keep my file completely find?
Excel passwords protect against casual access, but they are not military-grade encryption. If someone has technical skills and tools, they may be able to crack a weak password. Use a password that is at least 12 characters long and includes uppercase letters, numbers, and symbols for better security.