Preventing users from accessing VBE code

Dan Pensions

New Member
Joined
May 26, 2006
Messages
5
Hi, I have a spreadsheet which uses a macro.

The spreadsheet itself is protected with the exception of a few essential cells but I cannot seem to find a way of preventing the user from accessing the macro code by pressing alt-F11.

This is a particular problem as the code unlocks the cells temporarily while it updates some of them so the password is visible to all and can easily be changed.

As a result I am looking not only to write-protect the code but to hide it from the user completely.

Any suggestions as to how to achieve this will be greatly appreciated.

cheers, Daniel
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Excelenator

Board Regular
Joined
Jul 30, 2006
Messages
154
If you go to the VBE and right click on the project you want to protect, select properties, and then the tab for protection. You can then check the "Lock project for viewing" checkbox and type in a password and confirm it. Then save the project in the VBE and your code should be semi secure. Semi secure because this protection can be cracked with code easily obtained on the net, however, for novice users this probably won't be much of an issue.
 

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
The Lock Project for Viewing really only works with viewing the code from within the VBE (and as Excelenator has already mentioned, it isn't completely secure) - if someone was to open up the workbook eg in Notepad, it is still possible to reconstruct the code that you have created.

Best regards

Richard
 

Dan Pensions

New Member
Joined
May 26, 2006
Messages
5
Cheers guys all good now.

I did try that before but i didn't realise you had to exit and re-open the file so i thought it hadn't worked!

thanks, Daniel
 

Forum statistics

Threads
1,141,017
Messages
5,703,752
Members
421,313
Latest member
Mooncake1

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
Top