You can store them in a module in a newly created workbook which you save as an
Add-in or in your Personal.xls.
Sub ProtectAllSheets()
Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Sheets.Count
Sheets(n).Protect Password:="justme"
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:="justme"
Next n
Application.ScreenUpdating = True
End Sub
Sub Protect_Selected_Sheets()
Set MySheets = ActiveWindow.SelectedSheets
For Each ws In MySheets
ws.Select
ws.Protect Password:="justme"
Next ws
End Sub
Sub UnProtect_Selected_Sheets()
Set MySheets = ActiveWindow.SelectedSheets
For Each ws In MySheets
ws.Select
ws.UnProtect Password:="justme"
Next ws
End Sub
To prevent users from seeing the macros and password, protect the project from
viewing.
Alt + F11 to open Visual Basic Editor.
Select your workbook/project and right-click>VBAProject
Properties>Protection>Lock for Viewing.
Apply a unique password and save/close the workbook.
When re-opened, macros will be unviewable or uneditable.
You personally will still be able to run the macros just by typing the macroname
into the Tools>Macro>Macros dialog or using your super-secret shortcut key
combo.
I tried it and the macros are still visible in the Tools>Macro>Macros menu.
The Edit & Step Into bottons are greyed out, but the Run botton is not, so
users will still be able to select the macro and run it.
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.