질문하기질문하기
 

답변됨Grouping and unGrouping colums

  • 2009년 7월 8일 수요일 오후 3:08John Basedow 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    I need to group and colapse view or expand group, i dont want to group a colm if it is already, how can i tell if that column is grouped and if so show or not show?  
    McC

답변

  • 2009년 7월 9일 목요일 오후 3:03suznal 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨코드 있음
    To tell if a column is grouped, use the OutlineLevel property. If the level is greater than one it is part of a group...

    If Worksheets("Sheet1").Columns(2).OutlineLevel > 1 Then
        Range("A1").Value = "This column is part of a group"
    End If
    
    This can obviously be modified to loop through all columns on a sheet or a range as you need.

    To Hide or unhide use ShowLevels...

    ActiveSheet.Outline.ShowLevels RowLevels:=1
    
    The above will collapse all groups, leaving just Level 1 visible (level one are not part of groups).
    If there are three levels in the outline and you select 2 as RowLevels, level 2 will be visible but level three will be hidden (grouped).
    If you specify a number greater than the number of levels in an outline then all levels will be visible.

    This should get you started.



    "The new phonebooks are here!"
    • 답변으로 제안됨suznal 2009년 7월 9일 목요일 오후 3:06
    • 답변으로 표시됨Tim LiMSFT, 중재자2009년 8월 5일 수요일 오전 5:15
    •  

모든 응답

  • 2009년 7월 9일 목요일 오후 3:03suznal 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨코드 있음
    To tell if a column is grouped, use the OutlineLevel property. If the level is greater than one it is part of a group...

    If Worksheets("Sheet1").Columns(2).OutlineLevel > 1 Then
        Range("A1").Value = "This column is part of a group"
    End If
    
    This can obviously be modified to loop through all columns on a sheet or a range as you need.

    To Hide or unhide use ShowLevels...

    ActiveSheet.Outline.ShowLevels RowLevels:=1
    
    The above will collapse all groups, leaving just Level 1 visible (level one are not part of groups).
    If there are three levels in the outline and you select 2 as RowLevels, level 2 will be visible but level three will be hidden (grouped).
    If you specify a number greater than the number of levels in an outline then all levels will be visible.

    This should get you started.



    "The new phonebooks are here!"
    • 답변으로 제안됨suznal 2009년 7월 9일 목요일 오후 3:06
    • 답변으로 표시됨Tim LiMSFT, 중재자2009년 8월 5일 수요일 오전 5:15
    •  
  • 2009년 7월 9일 목요일 오후 3:04John Basedow 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Thanks thats exactly what i was looking for.

    BTW  DIE GAS PUMPER!!!!!        <-- This is a joke, do not call the FBI or the MSBI or ban me from the site!

    McC