I have a excel workbook report which is view by 5 persons. This report has 10 sheets, 9 of which are hidden using Sheets("Sheet2-10").Visible = xlVeryHidden
.
However, my worksheet is not secure because people can unhide worksheets 2 to 10 by using Sheets("Sheet2-10").Visible = true
(eg called from another workbook).
How do I protect my worksheet against someone trying to do this?
This doesn't completely solve your issue, but as an FYI, Excel allows you to name sheets beginning with a quotation mark followed by an apostrophe and then letters or anything else. So you could have a sheet named "'Sheet1. If you try Worksheets(""'Sheet1").Visible
, you get a compiler error. Users could still call it by index number however.
I think it's easy man. you just need to protect your VBA code with a password:
With this protection noone can see Microsoft Excel Object . So now, you just need to change your veryHidden sheet name to an awful name - hash name. like Sheets("FFJAR31GMCJ4ASAL8PYXXFE")
To make you like easier to code, you can set sheet's name in a constant.
Example:
Const MY_HIDDEN_SHEET As String = "FFJAR31GMCJ4ASAL8PYXXFE"
Sub f()
MsgBox "My hidden sheet name is " & MY_HIDDEN_SHEET
End Sub
Just protect your workbook structure:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.