Forum Discussion

KirkExcel's avatar
KirkExcel
Copper Contributor
Sep 10, 2024

Excel not password protecting VBA page properly...

Whenever I try to hide sheets and then password protect them in the VBA page it never works. Whenever I go back into the VBA page it just gives me immediate and full access without prompting me for a password. Any ideas? I am using Excel 365.

 

Thanks

  • Hermes_Santos14's avatar
    Hermes_Santos14
    Copper Contributor

    Hi KirkExcel 

     

    The protection of VBA in Excel 365 is slightly different from the conventional protection of worksheets. To properly protect the VBA code with a password, you need to follow some specific steps. Here they are:

    1. Open the VBA Editor:

      • Press Alt + F11 to open the VBA Editor.
    2. Access the Project Properties:

      • In the VBA Editor, right-click on your project (the folder with the name of your spreadsheet) in the "Project Explorer" window.
      • Select VBAProject Properties... from the drop-down menu.
    3. Set the Password:

      • In the Protection tab, check the Lock project for viewing box.
      • Enter and confirm the password in the appropriate fields.
    4. Save and Close:

      • Click OK and close the VBA Editor.
      • Save your spreadsheet.
    5. Close and Reopen Excel:

      • For the protection to take effect, you will need to completely close Excel and reopen the file.
      • Now, when trying to access the VBA code, the password will be requested.

    Important:

    • The password only protects access to the VBA code but does not prevent the execution of macros.
    • If the VBA project is not being properly locked, it could be a bug or issue with your version of Excel. Ensure that Excel 365 is up to date.

    This process should protect the VBA code from unauthorized access.

    • kirkbiddlecombe's avatar
      kirkbiddlecombe
      Copper Contributor

      Hermes_Santos14 

       

      Thanks for your reply, however I have tried the steps you outlined already and it does not work.

      Any other ideas?

       

      Many thanks for your time.

      • Hermes_Santos14's avatar
        Hermes_Santos14
        Copper Contributor
        I'm sorry you haven't found a solution for your case yet.
        Are you actually trying to hide the worksheet with VBA or hide the VBA codes in your workbook?

Resources