Consulting

Results 1 to 7 of 7

Thread: Group and ungroup certain rows in a protected sheets

  1. #1
    VBAX Regular
    Joined
    Sep 2008
    Posts
    23
    Location

    Group and ungroup certain rows in a protected sheets

    Help!! How do i write a macro to group and ungroup rows in a protected sheet? The tricky thing is, i would like the users to ungroup/group certain rows within the protected sheets. In addition, my workbook has a few protected sheets. Hence, the codes i have researched could not help me at all...

    Can someone pls help me?

    Rdgs,
    Helpless May

  2. #2
    VBAX Expert
    Joined
    Feb 2005
    Location
    Nanaimo, British Columbia, Cananda
    Posts
    568
    Location
    Hi May.

    Protect with userintferaceonly = true ?
    Cheers,

    dr

    "Questions, help and advice for free, small projects by donation. large projects by quote"

    http:\\www.ExcelVBA.joellerabu.com

  3. #3
    VBAX Regular
    Joined
    Sep 2008
    Posts
    23
    Location
    Errmmm.. how should i write my codes?

  4. #4
    Group Rows (rows 2 through to 7):

        Rows("2:7").Select
        Selection.Rows.Group
    Ungroup (row number 3)

        Rows("3:3").Select
        Selection.Rows.Ungroup
    Post Questions - Get Answers

  5. #5
    Unprotect the sheet:

        
        Sheets("Sheet1").Select
        ActiveSheet.Unprotect
    Protect the sheet:

        Sheets("Sheet1").Select
        ActiveSheet.Protect
    Post Questions - Get Answers

  6. #6
    VBAX Regular
    Joined
    Sep 2008
    Posts
    23
    Location
    Hi dr,

    how do you go about doing that? If you look at my attached file, i have many many groupings all over and i need to duplicate the files to different users. In addition, i have also a few sheets within the same workbook which have groupings and all the sheets are protected.

    Can you help?

    Thanks

    Regards,
    May



    Quote Originally Posted by rbrhodes
    Hi May.

    Protect with userintferaceonly = true ?

  7. #7
    VBAX Expert
    Joined
    Feb 2005
    Location
    Nanaimo, British Columbia, Cananda
    Posts
    568
    Location
    Hi May,

    Put this code in the ThisWorkBook module.

    <Alt +F11> to open the VB Editor.

    There are 2 windows you will need to see: The Code window- has 2 dropdown boxes above it. One will say General and the other will say Decarations. The Project Explorer window: a list of Excel 'Objects'.

    If you can see 'ThisWorkbook' in the Project Explorer window on the left, doubleclick on it. If you don't see the Project Explorer window use the View menu to open it, Click on the displayed objects '+' signs until you see ThisWorkbook, dbl click that.

    Paste this code in the 'Code' window (on the right). The Boxes at the top will change to 'Workbook' and 'Open'. This is good.

    Close the VBE, save and close the file. When you re-open you should have a fully protected set of sheets with Grouping enabled.



    [VBA]
    Option Explicit
    Private Sub Workbook_Open()

    Dim ws As Worksheet

    For Each ws In ThisWorkbook.Worksheets
    With ws
    .Protect Password:="PASSWORD", userinterfaceonly:=True
    .EnableOutlining = True
    End With
    Next ws

    End Sub

    [/VBA]
    Cheers,

    dr

    "Questions, help and advice for free, small projects by donation. large projects by quote"

    http:\\www.ExcelVBA.joellerabu.com

Posting Permissions

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