Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Posts
    233

    Unanswered: Run macro for rows that are not grouped?

    I would like to run a macro for each row that is not grouped, i can loop throught the rows but how do i tell if its grouped and not displayed or if its visable?

    I looked at outline level but it says unable to get property of the ....

  2. #2
    Join Date
    Sep 2008
    Location
    London, UK
    Posts
    511
    The trick to this seems to be that you have to check the outline property on a row by row basis, not a cell by cell basis.

    Code:
    Type GroupInfo
        IsGrouped As Boolean
        IsHidden As Boolean
    End Type
     
    Sub foo()
        Dim rngToCheck As Range
        Dim rngRow As Range
        Dim GroupInformation As GroupInfo
     
        Set rngToCheck = Range("A1:A21")
     
        For Each rngRow In rngToCheck.Rows
            GroupInformation = GetGroupInfo(rngRow)
            Debug.Print "Row:"; rngRow.Row; _
                        "Grouped= "; GroupInformation.IsGrouped; _
                        " Hidden= "; GroupInformation.IsHidden
        Next rngRow
     
    End Sub
     
     
    'you must pass in a 'Row' flagged type range, not a Cell type range
    Function GetGroupInfo(ByVal rngRowToCheck As Range) As GroupInfo
        GetGroupInfo.IsGrouped = (rngRowToCheck.OutlineLevel > 1)
        GetGroupInfo.IsHidden = rngRowToCheck.Hidden
    End Function


    Hope that helps...

Posting Permissions

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