need macro to delete any and all objects in a sheet (SOLVED)

kskinne

Well-known Member
Joined
Feb 17, 2002
Messages
1,267
Office Version
  1. 365
Platform
  1. Windows
I need a macro that will check to see if there are any objects in a sheet (pictures, etc.) and if there are, delete them all. Can anyone help me out?

Thank you,
Kevin
This message was edited by kskinne on 2002-10-29 10:01
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
I tried that code and it doesn't work in my spreadsheet - it is not deleting the picture in the sheet. Specifically, this is why I need this code:

I have a macro that copies the contents of one sheet as a picture, and then pastes the picture into a second sheet.

Sub copy_picture()
Application.ScreenUpdating = False
Sheets("invoice").Select
Range("A1:L53").CopyPicture
Sheets("copy of invoice").Select
Range("A5").Select
ActiveSheet.Paste
Application.ScreenUpdating = True
End Sub

What I need to do is add a line of code to the macro that will go to the second sheet first, and delete any picture that may have been previously pasted there, before the macro copies and pastes the picture.
 
Upvote 0
I tried that code and it doesn't work in my spreadsheet - it is not deleting the picture in the sheet. Specifically, this is why I need this code:

I have a macro that copies the contents of one sheet as a picture, and then pastes the picture into a second sheet.

Sub copy_picture()
Application.ScreenUpdating = False
Sheets("invoice").Select
Range("A1:L53").CopyPicture
Sheets("copy of invoice").Select
Range("A5").Select
ActiveSheet.Paste
Application.ScreenUpdating = True
End Sub

What I need to do is add a line of code to the macro that will go to the second sheet first, and delete any picture that may have been previously pasted there, before the macro copies and pastes the picture.
 
Upvote 0
You don't need a macro to delete all objects.

1. Press F5.
2. Press the Special button.
3. Click the radio button for Objects.
4. OK.

All objects on your sheet will now be active.
Hit the delete key on your keyboard.

Regards,

Mike
 
Upvote 0
That works fine, plus I discovered I can still automate this by inserting the code for this action as a line in my macro:

ActiveSheet.DrawingObjects.Delete

For some reason OLEObjects.delete didn't work but DrawingObjects.delete does.

Thanks for the help
kevin
 
Upvote 0
Yes, that's exactly what I did, so problem solved - thanks to all,

kevin
 
Upvote 0

Forum statistics

Threads
1,203,502
Messages
6,055,772
Members
444,822
Latest member
Hombre

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