Hide a Macro

G

gthing66

Hi all,

I have a multiple worksheets which i wish to password protect. I have
done so using the following VBA code:

Sub ProtectAllSheets()
Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Sheets.Count
Sheets(n).Protect Password:="XXXX"
Next n
Application.ScreenUpdating = True
End Sub


Sub UnprotectAllSheets()
Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Sheets.Count
Sheets(n).Unprotect Password:="XXXX"
Next n
Application.ScreenUpdating = True
End Sub

I do not wish others to be able to view this code as it defeats the
purpose of password protecting it.

How do i hide this macro but still be able to run it at my own
expense?

Cheers,
Grant.
 
G

Gord Dibben

Alt + F11 to open VBEditor.

Select your workbook.

Right-click on it and select VBAProject Properties>Protection>Lock for viewing
and give a password.

Note: you must save the file before the locking takes effect.


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top