ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Hide a Macro (https://www.excelbanter.com/excel-discussion-misc-queries/151626-hide-macro.html)

[email protected]

Hide a Macro
 
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.


Gord Dibben

Hide a Macro
 
Alt + F11 to open VBEditor.

Select your workbook.

Right-click on it and select VBAProject PropertiesProtectionLock for viewing
and give a password.

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


Gord Dibben MS Excel MVP



On Wed, 25 Jul 2007 04:46:17 -0700, wrote:

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.



[email protected]

Hide a Macro
 
Thanks for your help..worked perfectly!

grant.




All times are GMT +1. The time now is 05:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com