Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Mar 2002
    Location
    Quebec City, Quebec, Canada
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Protecting all sheets (Excel XP)

    I have recorded a macro to protect a single sheet : ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

    What code do I add to get it to protect all sheets in the workbook ?
    Something like:

    For each sheet in the workbook
    Protect using the current options for each sheet
    Next sheet

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protecting all sheets (Excel XP)

    Something like the following (untested):

    <pre>Dim oSheet as Worksheet
    For Each oSheet in Worksheets
    oSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    Next oSheet
    </pre>

    Legare Coleman

  3. #3
    Lounger
    Join Date
    Mar 2002
    Location
    Quebec City, Quebec, Canada
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protecting all sheets (Excel XP)

    Thanks Legare, works like a charm.

    It saves a lot of time. I have about 20 sheets in the workbook, and to make changes, it takes forever to unprotect then protect each sheet individually.
    I added a second macro to unprotect (oSheet.Unprotect), and now I can turn off my coputer and go to bed with a smile on my face...

    Good work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •