Delete all objects on sheet except...

J

JNW

I know I can use ActiveSheet.DrawingObjects.Delete to delete all drawing
objects on a sheet.

Is there a way to select all drawing objects EXCEPT for charts and text
boxes (or anything else for that matter)?
 
J

Joel

I have use this code before:

for each myshape in shapes

if instr(ucase(myshape.name),"CHART") = 0 then

msgbox(myshape.name)
end if

run code above once to make surre you are happy with the results. Then add

myshape.delete into the code.
 
J

JNW

Joel

Thanks for the reply. I'm not quite understanding what your code does. And
it is erroring at the for next line.

Thanks.
 
P

Peter T

Sub test()
Dim nType As Long
Dim shp As Shape

For Each shp In ActiveSheet.Shapes
nType = shp.Type
Select Case nType
Case msoChart, msoTextBox
' inlcude "or anything else for that matter" not to delete
Case Else
shp.Delete
End Select
Next
End Sub

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top