Pradeep Dsouza
Pradeep Dsouza

Reputation: 35

How do I add a new shape to an Existing Shape Group in Excel VBA?

I need help adding a new shape to an Existing Shape Group. Lets say I created a shapegroup after iterating through all shapes on Activesheet using the following code.

Set ShapeGroupX = ActiveSheet.Shapes.Range((x)).Group

Now if I add a new shape using Activesheet.shapes.AddShape and give it a unique name, how do I add this shape to ShapeGroupX without having to ungroup ShapeGroupX and group again?

Upvotes: 2

Views: 980

Answers (1)

Gary's Student
Gary's Student

Reputation: 96753

I think you will need to Ungroup followed by Group:

Sub MakeBigGroup()
    With ActiveSheet.DrawingObjects
        .Ungroup
        .Group
     End With
End Sub

Upvotes: 1

Related Questions