PDA

View Full Version : DELETING SYMBOLS



aoc
04-11-2007, 01:26 PM
Hi,

how can I delete symbols in the row 52 and 53 in the attached file ?

regards

Bob Phillips
04-11-2007, 02:14 PM
Run this bit of code.

For Each shp In ActiveSheet.Shapes
shp.Delete
Next shp

aoc
04-13-2007, 01:20 PM
can I delete without code ?


with code it deletes all of them not only the shape in row 52 and 53

mdmackillop
04-13-2007, 03:02 PM
Try
Sub DelShapes()
For Each shp In ActiveSheet.Shapes
If shp.TopLeftCell.Row = 52 Or shp.TopLeftCell.Row = 53 Then
shp.Delete
End If
Next shp
End Sub

aoc
04-14-2007, 07:31 AM
hi,

runtime error 1004

application-defined or object-defined error

what is the problem ?

mdmackillop
04-14-2007, 07:52 AM
On what line does the error occur?
Here's a slight modification to help show where the shapes are found
Option Explicit

Sub DelShapes()
Dim shp As Shape
MsgBox ActiveSheet.Shapes.Count
For Each shp In ActiveSheet.Shapes
shp.TopLeftCell.Interior.ColorIndex = 7
If shp.TopLeftCell.Row = 52 Or shp.TopLeftCell.Row = 53 _
Or shp.TopLeftCell.Row = 54 Then
shp.TopLeftCell.Interior.ColorIndex = 6
shp.Delete
End If
Next shp
MsgBox ActiveSheet.Shapes.Count
End Sub

aoc
04-14-2007, 08:23 AM
hi,

B53 becomes yellow.message says 26 then gives same error.
error line is shp.Delete

regards

mdmackillop
04-14-2007, 09:31 AM
:dunno I can't replicate the error. The yellow cell shows a shape has been found. You could try changing the code a bit to see in any shapes are deleted.
shp.TopLeftCell.Interior.ColorIndex = 6
MsgBox ActiveSheet.Shapes.Count
shp.Delete

aoc
04-14-2007, 02:21 PM
hi,

I could not solve the problem. please check the attached file. I want to delete the shapes in 52 and 53

regards

mdmackillop
04-14-2007, 02:46 PM
Try unprotecting the sheet.