VBA to Ungroup all shapes on a page?

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
Probably impossible, but I thought I would ask.

I need code to do this: When I select a range of cells, say E20:H24 then hit a button the code behind the button would ungroup all the shapes in that area. So if I have grouped shapes elsewhere, they would be uneffected.

Thank You in advance!!!
:-P Michael
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Michael

What is it you are actually trying to do?

I'm sure there's code out there to do what you describe, but I can't imagine it being particularly straightforward.

I'm envisaging the use of cell/shape co-ordinates and other properties like TopLeftCell.
 
Upvote 0
With the little knowledge I have, These sound like great possibilites.

Let's say I have Range E7:H16 selected. With a touch of a button, I would like any shape in this are to be ungrouped then deleted.
If I decide to to it in another area, do the same ie: A14:F35 is selected then any shape in the selection would be ungrouped and deleted.

Hope this is clearer,
Michael
 
Upvote 0
This code will delete any objects in the selected range.
Code:
Sub DeleteObjectFromSelection()
Dim isect As Range
    For Each PicObj In ActiveSheet.Shapes
        TheLeft = PicObj.TopLeftCell.Address
        Set isect = Application.Intersect(Range(TheLeft), Selection)
        If Not isect Is Nothing Then PicObj.Delete
    Next PicObj
End Sub
Don't know about bothering with "ungrouping" them first. If the objects are gone does that make a difference?
 
Upvote 0
Datsmart,
This is perfect!! :-D :-D
That is exactly what I have been looking for!!
:beerchug: :pray: :pray:
I have been trying to figure this one out for some time now. :o

Thank You, :) :)
Michael
 
Upvote 0

Forum statistics

Threads
1,223,914
Messages
6,175,353
Members
452,638
Latest member
Oluwabukunmi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top