Forum Discussion
Excel not password protecting VBA page properly...
I am wondering whether my Excel is broken.
Is there a workaround do you know? Like a VBA script I can write that will hide/lock the sheets somehow?
A silly question, but I need to know: Are you saving your spreadsheet macro-enabled (XLSM)?
Here are some examples you can use:
https://trumpexcel.com/excel-vba/hide-unhide-sheet/
https://trumpexcel.com/hide-worksheet/
- m_tarlerSep 11, 2024Steel Contributor
so it seems you have 2 different things here:
a) VBA protection - this only protects the VBA code from being editted or not
b) workbook protection - this is needed to prevent user from changing the overall structure of the workbook including hiding and unhiding sheets
as to why your VBA protection is not working I'm not sure but even if the protection is on you can still use the immediate window to hide or unhide a sheet or run macros you wrote to do the same.
to hide a sheet and stop it from showing you need to hide the sheet then enable workbook protection
this is under the Review tab:
EDIT: BTW I did some testing and if you try to turn on the VBA protection but do NOT have any macros/VBA code in the file, excel ignores it (I guess because there is no code to protect) Again, VBA protection does NOT protect from executing code, only from reading and/or modifying code that exists (and I wouldn't entrust that protection to anything too valuable/risky. e.g. don't embed your back account info in there or your patent pending next gen AI code and believe it is safe from malicious prying eyes)