delete pictures from worksheet

kwagner1

Active Member
Joined
Jun 10, 2003
Messages
445
is there a simple VB code that will remove all pictures from my file? i am currently using the following command to delete picture 2 - but i'm not always sure the picture will be named "pictured 2"....

current code:
ActiveSheet.Shapes("Picture 2").Select
Selection.Delete


thanks!
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

ADAMC

Well-known Member
Joined
Mar 20, 2007
Messages
1,169
Office Version
  1. 2013
Platform
  1. Windows
Hi

Try

ActiveSheet.Shapes(1).Delete
 
Upvote 0

ADAMC

Well-known Member
Joined
Mar 20, 2007
Messages
1,169
Office Version
  1. 2013
Platform
  1. Windows
Me again (",)

Try this:

Sub delete()
For Each shp In Sheets("Yoursheetnamehere").Shapes
shp.delete
Next

End Sub
 
Upvote 0

ADAMC

Well-known Member
Joined
Mar 20, 2007
Messages
1,169
Office Version
  1. 2013
Platform
  1. Windows
Me again (",)

Try this:

Sub delete()
For Each shp In Sheets("Yoursheetnamehere").Shapes
shp.delete
Next

End Sub
 
Upvote 0

kwagner1

Active Member
Joined
Jun 10, 2003
Messages
445
Adam - your first approach is what i need but i received an error when i tried to use it. Your other approaches rely on me knowing the shape name (that is what i am trying to avoid)

thanks!
 
Upvote 0

ADAMC

Well-known Member
Joined
Mar 20, 2007
Messages
1,169
Office Version
  1. 2013
Platform
  1. Windows
question

What error did you receive when using

Code:
Sub deleteshapes
ActiveSheet.Shapes(1).Delete
 
Upvote 0

ADAMC

Well-known Member
Joined
Mar 20, 2007
Messages
1,169
Office Version
  1. 2013
Platform
  1. Windows
question

What error did you receive when using

Code:
Sub deleteshapes
ActiveSheet.Shapes(1).Delete
end sub

Did you insert the code into a module?
 
Upvote 0

ADAMC

Well-known Member
Joined
Mar 20, 2007
Messages
1,169
Office Version
  1. 2013
Platform
  1. Windows
try this

Adam - your first approach is what i need but i received an error when i tried to use it. Your other approaches rely on me knowing the shape name (that is what i am trying to avoid)
thanks!

I think you may have misunderstood. You dont need to know shape name...Where i put yoursheetnamehere

Put the name of the actual sheet so..."Sheet1"
 
Upvote 0

kwagner1

Active Member
Joined
Jun 10, 2003
Messages
445
tried it again.... and now it worked! (i must have had screwed it up the first time)

ActiveSheet.Shapes(1).Delete

thanks Adam!
 
Upvote 0

Forum statistics

Threads
1,191,689
Messages
5,988,035
Members
440,125
Latest member
vincentchu2369

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
Top