Forum Discussion
Password protecting individual worksheets in excel so each person can only view and edit their own
Worksheet protection is notoriously weak. Even someone with little skill can google the instructions to break it. But, if you still wanted to do it, then you would need to use VBA. You should be able to get the user id using the environ function.
And, you would need to set up an event handler in the ThisWorkbook VBA module of your workbook to protect all sheets when opened, then get the user id and unprotect their sheet(s). You would also need to run the protectsheet routine before saving and the unprotect routine after saving.
Also, you would need to be sure to use the worksheet code names, which are viewable in the VBA project viewer or it is in the (Name) field when you click on the properties button in the developer tab, so that users can't circumvent your macro by changing the worksheet tab name. And, you would have to protect the VBA project so they can't easily get your passwords (but, this is also easy to break if one googles it).
If the data is sensitive and you cannot risk users intentionally getting to other worksheets, then you'll have to find another way as Excel's internal "security" is not secure if people make any effort to break it.
I attached an example, sort of a rough draft, to illustrate.
- dermotbAug 05, 2020Copper Contributor
That's pretty much what I suggested above.
I agree that Excel's security is weak. However, if the users aren't savvy and the data is not very sensitive, it is probably OK.
I believe, however, there is a really secure option, for extreme situations. The entire contents of each sheet could be AES encrypted in place using passwords unique to each page. The code would request a password and anything except the correct pass would result in gibberish.- JMB17Aug 05, 2020Bronze ContributorYes, I did not see your response until I refreshed the page.
If the user has to enter a password to decrypt a worksheet, then that seems to be as much work as having them enter a password to unprotect the sheet. And, an admin would have to enter passwords for all of the sheets. I'm assuming that is what the OP is trying to avoid, otherwise, I wouldn't see the point in asking?- dermotbAug 05, 2020Copper Contributor
JMB17
I suppose that is the problem with software that is designed to be open and collaborative - it isn't good at being secretive!
I have used AES encryption in several cases over the years, even encrypting individual rows of data with distinct passwords, so that users could "log in" and decrypt and use their individual data without the need for an internet connection.