Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Worksheet Functions / October 2007

Tip: Looking for answers? Try searching our database.

locking and unlocking worksheets

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
adam - 18 Jun 2007 15:00 GMT
Does anyone know of an add-in that allows you to lock and unlock multiple
worksheets at one time?
Gord Dibben - 18 Jun 2007 22:15 GMT
Here are 4 macros.

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

Gord Dibben  MS Excel MVP

>Does anyone know of an add-in that allows you to lock and unlock multiple
>worksheets at one time?
RL - 29 Oct 2007 22:32 GMT
Thanks, this works just fine.

The only problem I have is that any of the users of the workbook can run the
macro and unprotect all sheets.

Is there a way to hide the macro so it doesn't show up in Tools>macros or it
is possible password protect the macro?

Thanks,

> Here are 4 macros.
>
[quoted text clipped - 39 lines]
> >Does anyone know of an add-in that allows you to lock and unlock multiple
> >worksheets at one time?
Gord Dibben - 30 Oct 2007 01:41 GMT
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.

Gord

>Thanks, this works just fine.
>
[quoted text clipped - 49 lines]
>> >Does anyone know of an add-in that allows you to lock and unlock multiple
>> >worksheets at one time?
RL - 31 Oct 2007 16:18 GMT
Thanks for the quick answer.

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.

Any suggestions?
Thank you

> To prevent users from seeing the macros and password, protect the project from
> viewing.
[quoted text clipped - 67 lines]
> >> >Does anyone know of an add-in that allows you to lock and unlock multiple
> >> >worksheets at one time?
Gord Dibben - 31 Oct 2007 17:26 GMT
Apologies for the mis-direction.

At the top of the module and above the Subs enter this line

Option Private Module

Or change the Subs to Private Subs

Private Sub ProtectAllSheets()

Gord

>Thanks for the quick answer.
>
[quoted text clipped - 76 lines]
>> >> >Does anyone know of an add-in that allows you to lock and unlock multiple
>> >> >worksheets at one time?
RL - 31 Oct 2007 18:31 GMT
That worked. Thanks!!

> Apologies for the mis-direction.
>
[quoted text clipped - 88 lines]
> >> >> >Does anyone know of an add-in that allows you to lock and unlock multiple
> >> >> >worksheets at one time?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.