Deleting Objects from All sheets of a Workbook

pvkvimalan

New Member
Joined
Dec 19, 2017
Messages
27
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Dear All,

I have about 200 Worksheets in an Excel Workbook. All the sheets contain various objects. I initially started by selecting the objects by <Find & Select> <Goto Special><Objects> and delete all. I then managed to find a VBA within MrExcel, that was able to delete the objects, but only for active sheet, which means I have to run the code every single time. Could anyone help me to apply for the workbook as a whole?

The code I used as follows,


Sub DelShp()
Dim sh As Shape
For Each sh In ActiveSheet.Shapes
sh.Delete
Next sh
End Sub
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I would assume this would suit you just mine, my friend:
Code:
Sub DelShp_foreach_worksheet()

Dim ws As Worksheet
Dim sh As Shape

For Each ws In ActiveWorkbook.Worksheets
    ws.Select
        For Each sh In ActiveSheet.Shapes
            sh.Delete
        Next sh

Next ws

End Function
 
Upvote 0
How about
VBA Code:
Sub pvkvimalan()
   Dim Ws As Worksheet
   For Each Ws In Worksheets
      Ws.DrawingObjects.Delete
   Next Ws
End Sub
 
Upvote 0
Dear @Fluff & @ajetrumpet,

First of all, Thank you both for the swift response. I check both, while with the code from @ajetrumpet I received a compile error, whereas the code provided by @Fluff solved the issue. Appreciate both of your time and efforts.
 
Upvote 0

Forum statistics

Threads
1,224,732
Messages
6,180,622
Members
452,991
Latest member
JM_000888

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