Export (0) Print
Expand All
Expand Minimize

How to: Clear Groups in Worksheets

NoteNote

Some code examples in this topic use the this or Me keyword or the Globals class in a way that is specific to document-level customizations, or they rely on features of document-level customizations such as host controls. These examples can be compiled only if you have the required applications installed. For more information, see Features Available by Product Combination.

If you have groups of ranges in a Microsoft Office Excel 2003 worksheet, you can ungroup them using the Ungroup method.

The range can be one of two types:

Using Host Controls

The following code example assumes you have three previously grouped Microsoft.Office.Tools.Excel.NamedRange controls in a worksheet: data2001, data2002, and dataAll.

To clear groups of NamedRange controls in a worksheet

  • Call the Ungroup method.

    this.data2001.Ungroup();
    this.data2002.Ungroup();
    this.dataAll.Ungroup();
    
    

Using Excel Objects

This code example assumes you have programmatically added and grouped three native Excel ranges in the worksheet: data2001, data2002, and dataAll.

To clear groups of Excel Ranges in a worksheet

  • Call the Ungroup method.

    this.Application.get_Range("data2001", missing).Ungroup();
    this.Application.get_Range("data2002", missing).Ungroup();
    this.Application.get_Range("dataAll", missing).Ungroup();
    
    

Compiling the Code

  • This code must be placed in a sheet class, not in the ThisWorkbook class.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft