How to: Programmatically Group Rows in a Worksheet
You can group one or more whole rows. To create a group in a worksheet, use a NamedRange control or a native Excel range object.
Applies to: The information in this topic applies to document-level projects and application-level projects for Excel 2013 and Excel 2010. For more information, see Features Available by Office Application and Project Type.
If you add a NamedRange control to a document-level project at design time, you can use the control to programmatically create a group. The following example assumes that there are three NamedRange controls on the same worksheet: data2001, data2002, and dataAll. Each named range refers to a whole row in the worksheet.
To create a group of NamedRange controls on a worksheet
The code assumes that you have three Excel ranges named data2001, data2002, and dataAll on a worksheet.