ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete all objects on sheet except... (https://www.excelbanter.com/excel-programming/396120-delete-all-objects-sheet-except.html)

JNW

Delete all objects on sheet except...
 
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)?
--
JNW

joel

Delete all objects on sheet except...
 
I have use this code befo

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.

"JNW" wrote:

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)?
--
JNW


JNW

Delete all objects on sheet except...
 
Joel

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

Thanks.
--
JNW


"Joel" wrote:

I have use this code befo

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.

"JNW" wrote:

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)?
--
JNW


Peter T

Delete all objects on sheet except...
 
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


"JNW" wrote in message
...
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)?
--
JNW




Ron de Bruin

Delete all objects on sheet except...
 
You can use Type

See this page for a few examples
http://www.rondebruin.nl/controlsobjectsworksheet.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"JNW" wrote in message ...
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)?
--
JNW



All times are GMT +1. The time now is 10:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com