How to protect vba module in excel ?

If you are building a macro and don’t want any one to modify it. You have an option in Excel VBA editor, using which you can protect your VBA module code.

Open a new excel file

Go to Visual Basic Editor Window.

Insert new module and add a sample code to it.

Sub SampleCode()

Msgbox “This is a sample code we need to hide !”, vbInformation

End Sub

Follow the below steps to protect the VBA module:

Click on Tools

Click on VBA Project Properties

The VBA object properties window will pop up. On this window, select the Protection Tab.

Tick the Lock Project for viewing check box.

Enter the password of your choice in two fields, Password and Confirm Password.

Click OK and we have just protected the VBA module. Save and close the workbook. Open it again to check the protection.

Go to VBA module, all modules will be hidden and if you double click on it will ask you the password to unprotect.

Thank you for reading. Happy Learning !

Please leave a reply if you like the article or if you need any help on excel

%d bloggers like this: