Deleting all pictures / shapes in a range

toboggan

Board Regular
Joined
May 12, 2014
Messages
72
I've been searching and searching to find an answer for this and, while I've found many answers, none of them seem to be working for me. I'm trying to copy several rows and then paste them below. There is a specific area that will sometimes have pictures and/or shapes that I don't want to copy down to the newly created rows. So I'm trying to select the shapes within the newly created area and delete them.

Most of the code I've found so far seem to be some variation of this:

Code:
Dim sh As Shape
    For Each sh In ActiveSheet.Shapes
            If Not Intersect(Range("B454:AA480"), sh.TopLeftCell) Is Nothing And _
               Not Intersect(Range("B454:AA480"), sh.BottomRightCell) Is Nothing Then
                sh.Delete
            End If
        Next sh

However, this code is giving me Run-time error '1004': Application-defined or object-defined error.


Weird thing is. I ran it once and it seemed to work, but if I delete the rows that were created and run the macro again, I continuously get the error above.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Just tried it again. Inserted only a rectangle and it worked. Then I deleted the created rows and ran the macro again to recreated them and it gave me the error.
 
Upvote 0
In fact, I then deleted the rectangle and tried to run it again, and it's still giving me the error.
 
Upvote 0
Unfortunately there's a ton of proprietary info all over the document. Not so sure that'll work.
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

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