If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Run macro for rows that are not grouped?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-20-10, 16:43
mikezx10 mikezx10 is offline
Registered User
 
Join Date: Oct 2003
Posts: 226
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 ....
Reply With Quote
  #2 (permalink)  
Old 05-21-10, 06:10
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
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...
__________________
Colin

RAD Excel Blog

Other tutorials:
Array Formulas | Deleting Rows with VBA
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On