How to hide/disable VBA interface on protected sheet?

Kelvin Stott

Active Member
Joined
Oct 26, 2010
Messages
338
Hi,

Thanks for all the help so far! I've now completed my model, but have encountered the following security issue when I try to protect my sheet:

I have added the following code to enable grouping/ungrouping on my protected sheet, but the VBA interface and code can still be opened (and even changed!) while the sheet is protected, so my supposedly secret password becomes visible, which defeats the whole point of protecting it!

Code:
Private Sub Workbook_Open()
    With Sheet1
       .Protect Password:="my password", UserInterfaceOnly:=True
       .EnableOutlining = True
    End With
End Sub

So: How can I hide and disable the VBA interface so that none of the macros can be opened or edited while the sheet is protected? :confused:

Thanks for any help/guidance on this. :)
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
You could protect the project.

Open the VBE (ALT+F11)
Tools > VBA Project Properties
Enter password in Protection tab
Check Lock Project for Viewing
 
Upvote 0
Open up the visual basic editor
In the project explorer window, right click on your project > properties
Protection tab
Tick the 'Lock project for viewing' checkbox
Type in and confirm a password (remember it)
OK

Save, close and re-open your project. The VBA code can only be viewed if you know the password.
 
Upvote 0
In the VBE, Tools > VBA Project Properties, Protection tab, tick Lock project for viewing and enter a password. Save, close and re-open the workbook to see the effect.

Note that this won't stop a determined hacker.
 
Upvote 0

Forum statistics

Threads
1,215,693
Messages
6,126,248
Members
449,304
Latest member
hagia_sofia

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top