Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I have a file that has been growing and now is over 8 MB. I checked lots of
things from similar discussions and when I ran this from Ron de Bruin it went from 8.31MB to 822 KB Sub Shapes1() 'Delete all Objects except Comments On Error Resume Next ActiveSheet.DrawingObjects.Visible = True ActiveSheet.DrawingObjects.Delete On Error GoTo 0 End Sub So on the original worksheet tabs I tried this from another discussion ?activesheet.shapes.count 10439 ?activesheet.shapes.count 20567 No wonder! I should have zero on the first one and 20 (buttons which have "send report" on the face and are tied to macros) on the second one. How can I adapt the "Shapes Deleting" macro to not eliminate the ones I want when try to get rid of the other 20547 on the one sheet? |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Dear Steve
Mention the 20 shape names as a comma separated string...like below and run the below macro.... Make sure the names are exactly same as the shape names....For example the by default name for Rectangle come as 'Rectangle 1' and not 'Rectangle1'...Try and feedback Sub Macro() Dim lngTemp As Variant Dim strShapes As String strShapes = "Rectagle 10,Rectangle 2,Rectangle 31" strShapes = strShapes & ",Rectagle 32,Rectangle 35,Rectangle 70" For lngTemp = 1 To ActiveSheet.Shapes.Count If InStr(1, "," & strShapes & ",", "," & ActiveSheet. _ Shapes(lngTemp).Name & ",", vbTextCompare) = 0 Then ActiveSheet.Shapes(lngTemp).Delete End If Next End Sub -- If this post helps click Yes --------------- Jacob Skaria "Steve" wrote: I have a file that has been growing and now is over 8 MB. I checked lots of things from similar discussions and when I ran this from Ron de Bruin it went from 8.31MB to 822 KB Sub Shapes1() 'Delete all Objects except Comments On Error Resume Next ActiveSheet.DrawingObjects.Visible = True ActiveSheet.DrawingObjects.Delete On Error GoTo 0 End Sub So on the original worksheet tabs I tried this from another discussion ?activesheet.shapes.count 10439 ?activesheet.shapes.count 20567 No wonder! I should have zero on the first one and 20 (buttons which have "send report" on the face and are tied to macros) on the second one. How can I adapt the "Shapes Deleting" macro to not eliminate the ones I want when try to get rid of the other 20547 on the one sheet? |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Another way is to select the cell range of shapes which are to be kept...The
below macro will remove all other shapes from the Active worksheet. Sub RemoveShapes() Dim rngMyRange As Range Dim shpMyShape As Shape Set rngMyRange = Selection For Each shpMyShape In ActiveSheet.Shapes If Application.Intersect(rngMyRange, shpMyShape.TopLeftCell) _ Is Nothing Then shpMyShape.Delete Next shpMyShape End Sub -- If this post helps click Yes --------------- Jacob Skaria "Steve" wrote: I have a file that has been growing and now is over 8 MB. I checked lots of things from similar discussions and when I ran this from Ron de Bruin it went from 8.31MB to 822 KB Sub Shapes1() 'Delete all Objects except Comments On Error Resume Next ActiveSheet.DrawingObjects.Visible = True ActiveSheet.DrawingObjects.Delete On Error GoTo 0 End Sub So on the original worksheet tabs I tried this from another discussion ?activesheet.shapes.count 10439 ?activesheet.shapes.count 20567 No wonder! I should have zero on the first one and 20 (buttons which have "send report" on the face and are tied to macros) on the second one. How can I adapt the "Shapes Deleting" macro to not eliminate the ones I want when try to get rid of the other 20547 on the one sheet? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
"Growing" File Size: A Solution | Excel Discussion (Misc queries) | |||
Saving Excel (2003) File Causes Growing Size | Excel Discussion (Misc queries) | |||
File Size Keeps Growing On Import | Excel Discussion (Misc queries) | |||
Excel Spreadsheet growing in size for no reason | Excel Discussion (Misc queries) | |||
Shared Excel File keeps growing........ | Excel Discussion (Misc queries) |