Home

General XL Tips

XL Formulae

Using VBA with XL

XL VBA Functions

XL VBA Macros

Mac XL

This site will look better if you upgrade to a browser that supports web standards.

Protect and Unprotect Grouped Sheets

When sheets are grouped (e.g., shift clicking on multiple sheets), they can no longer be password protected, since protection takes place on the sheet level. Here's a quick routine to unselect the grouped sheets, protect them individually, then group them again:

    Public Sub ProtectGroupedSheets()
        Const csPASSWD As String = "drowssap"
        Dim mySheets As Sheets
        Dim actSheet As Worksheet
        Dim wkSht As Worksheet

        Set actSheet = ActiveSheet
        Set mySheets = ActiveWindow.SelectedSheets
        actSheet.Select
        For Each wkSht In mySheets
            wkSht.Protect Password:=csPASSWD
        Next wkSht
        actSheet.Select
        mySheets.Select False
    End Sub

Unprotect just uses .Unprotect instead of .Protect

Valid XHTML 1.1 Valid CSS Made on a Macintosh

Quick Links

Unfamilar with macros? See David McRitchie's Getting Started with Macros and User Defined Functions.