Forum Discussion
Disable View Code in Protected Worksheets
I have looked everywhere, but can find no answer to my question. I am using some VBA to dynamically show and hide rows and columns based on selections in my worksheets. In attempting to protect these worksheets I can find no way to prevent users from selecting "View Code" and being able to edit the VBA. The contents of the worksheets are protected, but not the underlying code. Help!
Activate the Visual Basic Editor.
Select Tools > VBAProject Properties...
Activate the Protection tab.
Tick the check box 'Lock project for viewing'.
Enter a password in the Password box, and enter it again in the 'Confirm password' box.
Don't forget this password - you'll need it later if you want to view/edit the VBA code!
Click OK.
Save the workbook.
Close and reopen the workbook. You'll find that you cannot view the code if you cannot provide the password.
Warning: this is not 100% tamper-proof. There are ways to disable the password.
3 Replies
Activate the Visual Basic Editor.
Select Tools > VBAProject Properties...
Activate the Protection tab.
Tick the check box 'Lock project for viewing'.
Enter a password in the Password box, and enter it again in the 'Confirm password' box.
Don't forget this password - you'll need it later if you want to view/edit the VBA code!
Click OK.
Save the workbook.
Close and reopen the workbook. You'll find that you cannot view the code if you cannot provide the password.
Warning: this is not 100% tamper-proof. There are ways to disable the password.
- JennW_IWCOCopper ContributorThank you so much! This works perfectly. I really appreciate the speedy and helpful response!
You're welcome!