Results 1 to 2 of 2

Thread: Enable Grouping Or Outline Or Outlining On A Protected Excel Worksheet

  1. #1
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10

    Lightbulb Enable Grouping Or Outline Or Outlining On A Protected Excel Worksheet

    A lot of times we come across situations where we need to use the Grouping / Outlining feature in Excel, but at the same time we want to protect the sheet too. Excel doesn't provide an option to do this via the sheet protection window that pops up while protecting a sheet. However, this can easily be achieved using VBA. Here's how (paste it in a module)

    Code:
    Private Sub Auto_Open()
    
        Dim wks As Worksheet
        
        For Each wks In Worksheets
            With wks
               .Protect Password:="YourPassWordHERE", UserInterfaceOnly:=True
               .EnableOutlining = True
            End With
        Next wks
    
    End Sub

  2. #2
    Senior Member
    Join Date
    Mar 2013
    Posts
    107
    Rep Power
    12
    Hi Excel Fox

    Used the code below but still asks to unprotect sheet otherwise does not work

    Code:
    Private Sub Auto_Open()
    
        Dim wks As Worksheet
        
        For Each wks In Worksheets
            With wks
               .Protect Password:="YourPassWordHERE", UserInterfaceOnly:=True
               .EnableOutlining = True
            End With
        Next wks
    
    End Sub

Similar Threads

  1. Workbook protected when using this code
    By raybugge in forum Excel Help
    Replies: 1
    Last Post: 07-08-2013, 07:15 PM
  2. Print Nth Worksheet To Mth Worksheet using VBA
    By Ryan_Bernal in forum Excel Help
    Replies: 2
    Last Post: 02-28-2013, 06:57 PM
  3. Outline By Customer Name
    By mrmmickle1 in forum Excel Help
    Replies: 3
    Last Post: 12-04-2012, 10:41 PM
  4. Adding charts via code to a protected sheet
    By Rasm in forum Excel Help
    Replies: 2
    Last Post: 11-14-2012, 05:11 PM
  5. VBA to Create Grouping (Difficult)
    By Biz in forum Excel Help
    Replies: 4
    Last Post: 07-12-2011, 03:25 AM

Tags for this Thread

Posting Permissions

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