View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
shockley shockley is offline
external usenet poster
 
Posts: 135
Default Selecting drawing objects or shapes in a macro

This will delete the shape in the active cell (assuming the shape occupies
only one cell) and clear the contents of the active cell, which is what I
think you want to do (I don't guarantee this is the easiest way):

Sub Tester2()
With ActiveSheet
For i = 1 To .Shapes.Count
x = .Shapes(i).TopLeftCell.Row
y = .Shapes(i).TopLeftCell.Column
If ActiveCell.Address = .Cells(x, y).Address Then
.Shapes(i).Delete
ActiveCell.ClearContents
Exit For
End If
Next i
End With
End Sub

HTH,
Shockley


"John DeFiore" wrote in message
...
I have an application where an Excel cell contains either
a red dot or a red dot with a circle around it. These are
drawing objects or shapes. When I delete the contents of
a cell, they stay put. I have to select them individually
and delete them, which is what I want to automate with a
bit of code. What I want to do is delete the dot within
the active cell, and delete the contents of the cell. I
just can't figure out how to select the dot in the active
cell without knowing the individual shape range. What I
want to do is:

ActiveSheet.Shapes("Oval 955").Select

But I want to select whichever "Oval" is in the active
cell. Is that possible?

Thanks,

John