To apply a password to the VBA code in a workbook, activate the VBE and select your project in the Projects window. Then choose Tools ^ xxxx Properties (where xxxx corresponds to your Project name). This displays the Project Properties dialog box.
In the Project Properties dialog box, click the Protection tab (see Figure 2-17). Enable the Lock Project for Viewing check box and enter a password (twice). Click OK and then save your file. When the file is closed and then re-opened, a password will be required to view or modify the code.
It's important to keep in mind that Excel is not really a secure application. The protection features, even when used with a password, are intended to prevent casual users from accessing various components of your workbook. Anyone who really wants to defeat your protection can probably do so by using readily available password-cracking utilities (or by knowing a few "secrets").
Was this article helpful?