WITH password or WITHOUT?

Depending on what options you want on the "protect", you can use:
'-------------------------------------------------------------------
Option Explicit
Sub Protect_all()
    Dim pw_ent, sht
    pw_ent = "test"
    For Each sht In ThisWorkbook.Sheets
        ThisWorkbook.Sheets(sht.Name).Protect _
        DrawingObjects:=True, _
        Contents:=True, _
        Scenarios:=True, _
        AllowFormattingCells:=True, _
        AllowFormattingColumns:=True, _
        AllowFormattingRows:=True, _
        AllowInsertingColumns:=True, _
        AllowInsertingRows:=True, _
        AllowDeletingColumns:=True, _
        AllowDeletingRows:=True, _
        AllowSorting:=True, _
        AllowFiltering:=True, _
        AllowUsingPivotTables:=True, _
        Password:=pw_ent
    Next sht
End Sub
Sub Unprotect_all()
    Dim sht, pw_ent
    pw_ent = "test"
        For Each sht In ThisWorkbook.Sheets
            ThisWorkbook.Sheets(sht.Name).Unprotect Password:=pw_ent
        Next sht
End Sub  
'-------------------------------------------------------------------
You should record a macro in which you protect a sheet with the appropriate
permissions in order to know what options to use.

hope this helps,
Paul





________________________________
From: suresh k <brave.sur...@gmail.com>
To: Excel group <excel-macros@googlegroups.com>
Sent: Thursday, May 21, 2009 10:41:44 AM
Subject: $$Excel-Macros$$ Protect and unprotect all sheets

Hi All,

Can anyone provide the vba code to protect and unprotect all sheets in excel.

Thanks & regards,
Suresh


--~--~---------~--~----~------------~-------~--~----~
-------------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at 
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 

To post to this group, send email to excel-macros@googlegroups.com
If you find any spam message in the group, please send an email to:
Ayush Jain  @ jainayus...@gmail.com or
Ashish Jain @ 26may.1...@gmail.com
-------------------------------------------------------------------------------------
-~----------~----~----~----~------~----~------~--~---

Reply via email to