Making my spreadsheets "Hack Proof"

danelskibr

Board Regular
Joined
Dec 31, 2014
Messages
58
Hello,

I have a spreadsheet that is shared with people throughout the company, but what they can see and do with the spreadsheet is limited

I have password protection on the VBA Project, the workbook, and all the sheets.

I allow the users to interact with the spreadsheet through macros. When a user clicks a button to run a macro, the macro will unprotect certain portions of the workbook in order to run without errors. At the end of the macro, code runs to protect everything once again.

The problem is that if I run the macro and then hit the "Esc" key repeatedly, I will break the macro in the middle of it running and after it has unprotected certain parts of the workbook. This allows the user a way into the protected aspects of the sheets.

Is there a way to prevent this type of breach?

Thank you for your help!
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
You can use UserInterfaceOnly parameter of Sheets.Protect method to specify that password protection applies only to UI and not to macro. With that, you macro will no longer need to first call Unprotect method to work on the sheet. So even if the macro crashes, the sheet UI is still protected.

Code:
Sheets("Sheet1").Protect Password:="abcd", UserInterfaceOnly:=True
 
Upvote 0
Thank you for that! This is a much better solution than calling unprotect macros.

Can the same logic be applied to unprotecting the workbook?

Thanks again!
 
Upvote 0
First, I should point out that you can't make a workbook hack proof.

There is no equivalent to the UserInterfaceonly parameter for workbook protection (and you should be aware that UIO is not 100% reliable in allowing worksheet operations) but you can use the Application.EnableCancelKey property to disable the Esc key while your code is running.
 
Upvote 0
I figured I might get a little flack for that title! That is why I put hack-proof in quotes. Most people don't know how to unhide columns in my world, so password protected worksheets are pretty much impenetrable. :)

Thanks for the response. I will give that a shot!
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,392
Members
449,081
Latest member
JAMES KECULAH

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