Re: Is there a quick way to lock all pages in a workbook at one time?

From: Gord Dibben (gorddibbATshawDOTca)
Date: 10/29/04


Date: Fri, 29 Oct 2004 16:08:01 -0700

teckie

By "pages" I assume you mean "worksheets".

You can Protect all sheets using the Macro code below.

I also provide an "Unprotect" macro.

Sub ProtectAllSheets()
    Application.ScreenUpdating = False
    Dim n As Single
    For n = 1 To Sheets.Count
        Sheets(n).Protect Password:="password"
    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:="password"
    Next n
    Application.ScreenUpdating = True
End Sub

Be sure to protect the VBA Project so's your users can't see the "password".

If not familiar with VBA and macros, see David McRitchie's site for more on
"getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + R to open Project Explorer.

Find your workbook/project and select it.

Right-click and Insert>Module. Paste the above code in there. Save the
workbook and hit ALT + Q to return to your workbook.

Run the macro by going to Tool>Macro>Macros.

Gord Dibben Excel MVP

On Fri, 29 Oct 2004 14:27:03 -0700, teckie <teckie@discussions.microsoft.com>
wrote:

>I have several wrokbooks that have 20 to 50 pages each. I want users to be
>able to view or print the informatin, but not change the data. Any
>suggestions on how to secure all the pages at one time?


Loading