Microsoft Developer Network >
Página Inicial dos Fóruns
>
Visual Basic for Applications (VBA)
>
Grouping and unGrouping colums
Grouping and unGrouping colums
Respostas
- To tell if a column is grouped, use the OutlineLevel property. If the level is greater than one it is part of a group...
This can obviously be modified to loop through all columns on a sheet or a range as you need.If Worksheets("Sheet1").Columns(2).OutlineLevel > 1 Then Range("A1").Value = "This column is part of a group" End If
To Hide or unhide use ShowLevels...
The above will collapse all groups, leaving just Level 1 visible (level one are not part of groups).ActiveSheet.Outline.ShowLevels RowLevels:=1
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!"- Sugerido como Respostasuznal quinta-feira, 9 de julho de 2009 15:06
- Marcado como RespostaTim LiMSFT, Moderadorquarta-feira, 5 de agosto de 2009 5:15
Todas as Respostas
- To tell if a column is grouped, use the OutlineLevel property. If the level is greater than one it is part of a group...
This can obviously be modified to loop through all columns on a sheet or a range as you need.If Worksheets("Sheet1").Columns(2).OutlineLevel > 1 Then Range("A1").Value = "This column is part of a group" End If
To Hide or unhide use ShowLevels...
The above will collapse all groups, leaving just Level 1 visible (level one are not part of groups).ActiveSheet.Outline.ShowLevels RowLevels:=1
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!"- Sugerido como Respostasuznal quinta-feira, 9 de julho de 2009 15:06
- Marcado como RespostaTim LiMSFT, Moderadorquarta-feira, 5 de agosto de 2009 5:15
- 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- EditadoJohn Basedow quinta-feira, 9 de julho de 2009 15:07

