vba prevent user to see macro code in Excel

Q148. In Excel, how can I prevent users from seeing / accessing my macro code?

For example, I have a very complex macro based WorkBook that I share with people outside my organization. I would like to prevent outsiders from accessing my macro code.

This is also very useful to protect your VBA code that against copy and to protect your copyrights.

VBA code password protection is a good thing to do when you spent a lot of hours developing some code and that you do not want to be copied or modified

To do it in Excel, here is the answer:

a) In the VBA Editor, right click on "VBAProject (FILE)". Click on "VBAProject Properties".

excel vba prevent user to see macro code

b) "VBAProject - Project Properties" window pops up. Click on "Protection" tab.

excel excel vba prevent user to see macro code

c) Check "Lock project for viewing". Enter a Password. Confirm Password. Click OK.

excel excel excel vba prevent user to see macro code

d) When the file is opened the next time, a "VBAProject Password" dialog pops up. To gain access to the code, right password has to be entered.

excel excel excel excel vba prevent user to see macro code

 

You can find similar Excel Questions and Answer hereunder

1) How can I get users to select a folder to save the output of my macro?

2) Calling a macro from another workbook in Excel

3) I have a macro that takes a lot of time for execution - how can I keep the user informed that the macro is running?

4) How do I add a symbol like Triangle / Inverted Triangle for indicating trends in a cell using VBA?

5) Excel 2010 vba replacement of application filesearch in Excel

6) How can I access previously auto saved versions of my current Excel workbook?

7) How can I add a Timestamp after macro execution?

8) How can I add Trendline to a chart using VBA?

9) I want to automatically run an initialization procedure whenever I open my WorkBook so that it is ready for use - how can I achieve that?

10) How can I have text autocomplete by typing in a short code for the text?

11) How can I filter and copy only filtered data using VBA?

12) How can I prevent users from entering duplicate values in a range?

13) How can I get the count of number of series in a Chart using VBA?

14) How can I save a WorkSheet as a new WorkBook using VBA?

15) How can I update a listbox based on data in a list using VBA?