Ungroup Method

Microsoft Excel Visual Basic

Promotes a range in an outline (that is, decreases its outline level). The specified range must be a row or column, or a range of rows or columns. If the range is in a PivotTable report, this method ungroups the items contained in the range.

expression.Ungroup

expression    Required. An expression that returns a Range object.

Remarks

If the active cell is in a field header of a parent field, all the groups in that field are ungrouped and the field is removed from the PivotTable report. When the last group in a parent field is ungrouped, the entire field is removed from the report.

ShowUngroup method as it applies to the Shape and ShapeRange objects.

Ungroups any grouped shapes in the specified shape or range of shapes. Disassembles pictures and OLE objects within the specified shape or range of shapes. Returns the ungrouped shapes as a single ShapeRange object.

expression.Ungroup

expression    Required. An expression that returns one of the above objects.

Remarks

Because a group of shapes is treated as a single object, grouping and ungrouping shapes changes the number of items in the Shapes collection and changes the index numbers of items that come after the affected items in the collection.

Example

ShowAs it applies to the Range object.

This example ungroups the ORDER_DATE field.

Set pvtTable = Worksheets("Sheet1").Range("A3").PivotTable
Set groupRange = pvtTable.PivotFields("ORDER_DATE").DataRange
groupRange.Cells(1).Ungroup
				

ShowAs it applies to the Shape and ShapeRange objects.

This example ungroups any grouped shapes and disassembles any pictures or OLE objects on myDocument.

Set myDocument = Worksheets(1)
For Each s In myDocument.Shapes
    s.Ungroup
Next
				

This example ungroups any grouped shapes on myDocument without disassembling pictures or OLE objects on the document.

Set myDocument = Worksheets(1)
For Each s In myDocument.Shapes
    If s.Type = msoGroup Then s.Ungroup