Modify VBA from all worksheets to specific worksheet

LNG2013

Active Member
Joined
May 23, 2011
Messages
465
How can I change the below code to only remove the pictures from worksheet "Imports" instead of all worksheets. Thankyou in advance!


VBA Code:
Sub BaDeletePictures()

' This macro removes all the pictures and objects that come over from the spreadsheet

   Dim oPic As Shape
   Dim wb As Workbook
   Dim ws As Worksheet
   'Loop through all worksheets
   For Each ws In ActiveWorkbook.Worksheets
   'Loop through all objects in the selected worksheet
      For Each oPic In ws.Shapes
      'Delete object
         oPic.Delete
      Next oPic
   Next ws
End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
A little adjust :

VBA Code:
Sub BaDeletePictures()

' This macro removes all the pictures and objects that come over from the spreadsheet

   Dim oPic As Shape
   Dim wb As Workbook
   Dim ws As Worksheet
   'Loop through all worksheets
For Each oPic In Worksheets("Imports").Shapes
    oPic.Delete
Next oPic

End Sub
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,186
Members
448,554
Latest member
Gleisner2

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