Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shapes.selectall deletes a command button on a worksheet.

Status
Not open for further replies.

Expressline99

Technical User
Jul 25, 2008
11
US
I'm sure this is a simple question however for the life of me I cannot figure it out. First off I'm using VBA in excel 2000.

I have a worksheet that gets information copied and pasted into it from the web(manually). When this happens it brings in an unknown number of Shapes("Picture 1") 's

I placed a simple command button on the sheet to be pressed to delete these pictures. Using the following.

Set MyDocument = ActiveSheet
MyDocument.Shapes.SelectAll
Selection.Delete

While this deletes all the pictures it also deletes my command button. As well, when I manually select the entire worksheet to be deleted then follow that by pushing the cmd button it runs out of memory and gives a memory error.

What can I do here.

Paul :)
 





Hi,
Code:
dim shp as shape
for each shp in ActiveSheet.shapes
  if shp.name <> "YourButtonName" then shp.delete
next


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Great thank you. Any ideas as to why I would get that memory error?

Paul
 



What memory error?

Tested and works!

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Oh no memory error with your code. Only with previous code so I've resolved both issues with your answer. Simple and quick just what I wanted!

Thanks, again :)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top