Return to VBA Code Examples

VBA Group Rows & Columns

This tutorial will demonstrate how to group and ungroup rows and columns in VBA.

Group Rows or Columns

To group rows or columns apply the Group Method to the rows or columns:

Rows("3:5").Group

or

Columns("C:D").Group

Ungroup Rows or Columns

To ungroup the rows or columns, simply use the Ungroup Method:

Rows("3:5").Ungroup

or

Columns("C:D").Ungroup

Expand All “Grouped” Outline Levels

To expand all grouped outline levels, use this line of code:

ActiveSheet.Outline.ShowLevels RowLevels:=8, ColumnLevels:=8

To collapse all outline levels, use this line of code:

ActiveSheet.Outline.ShowLevels RowLevels:=1, ColumnLevels:=1

 

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users! vba save as


Learn More!