+ Reply to Thread
Results 1 to 5 of 5

Macro and grouping not working in Protected sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    07-18-2012
    Location
    germany
    MS-Off Ver
    Excel 2007
    Posts
    6

    Macro and grouping not working in Protected sheet

    Hello,
    I have the following macro code in my "Overview" excel sheet. I recorded the macro and it works perfectly.

    The problem is that i have grouped some fields and after the sheet is protected, the grouping doesnt work anymore.
    It says remove the protection and try again. I have used no password to protect the file.


    Sub Add_Row_Sort()
    '
    ' Add_Row_Sort Macro
    ' Add a row and sort by deadline and priority
    '
    
    '
        Application.ScreenUpdating = False
        ActiveSheet.Unprotect
        Range("B9:Y9").Select
        Selection.ListObject.ListRows.Add (2)
        ActiveWorkbook.Worksheets("Overview").ListObjects("Table1").Sort.SortFields. _
            Clear
        ActiveWorkbook.Worksheets("Overview").ListObjects("Table1").Sort.SortFields. _
            Add Key:=Range("Table1[Deadline]"), SortOn:=xlSortOnValues, Order:= _
            xlAscending, DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets("Overview").ListObjects("Table1").Sort.SortFields. _
            Add Key:=Range("Table1[Prio]"), SortOn:=xlSortOnValues, Order:= _
            xlAscending, DataOption:=xlSortNormal
        With ActiveWorkbook.Worksheets("Overview").ListObjects("Table1").Sort
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
        ActiveSheet.Protect
        Application.ScreenUpdating = True
        Range("B8").Select
    End Sub

    Thanks in advance,

    Ranju
    Last edited by ranjuv; 08-27-2012 at 08:47 AM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Macro and grouping not working in Protected sheet

    Now i want to protect the sheet and when i do that, the macro gives an error.
    What error?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    07-18-2012
    Location
    germany
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Macro and grouping not working in Protected sheet

    Arlette,

    Sorry.. it gives an error now only with the grouping part. Rest is fine. I will edit the question.

    Ranju

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Macro and grouping not working in Protected sheet

    Do you do the grouping manually or via code? I do not see any code for grouping the rows in post 1.

  5. #5
    Registered User
    Join Date
    07-18-2012
    Location
    germany
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Macro and grouping not working in Protected sheet

    I did it manually. After grouping, when i protect the sheet, the grouping doesnt work. I found some codes in the internet as a solution but i dont know where to include those... like if i should include them in between the current code or include them as a different object.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1