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:

or

Ungroup Rows or Columns

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

or

Expand All “Grouped” Outline Levels

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

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